I am looking for a script which grabs the Followers from multiple Social Media Sites to one XML.
Example:
I do have multiple Social Media Channels, e.g.:
- facebook.com/fbchannel1
- facebook.com/fbchannel2
- twitter.com/twchannel1
- twitter.com/twchannel2
- youtube.com/user/ytchannel1
- youtube.com/user/ytchannel2
- plus.google.com/11111/
- plus.google.com/22222/
Now I want to sum up all the Followers of each network, say:
- facebook.com/fbchannel1 //200 Followers
- facebook.com/fbchannel2 //300 Followers
= 500 FB Followers
- twitter.com/twchannel1 //200 Followers
- twitter.com/twchannel2 //300 Followers
= 500 TW Followers
- youtube.com/user/ytchannel1 //200 Followers
- youtube.com/user/ytchannel2 //300 Followers
= 500 YT Followers
- plus.google.com/11111/ //200 Followers
- plus.google.com/22222/ //300 Followers
= 500 G+ Followers
The script should then put these data into the following XML:
<?xml version="1.0" standalone="yes"?><socialMedia xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<social>
<network>Facebook</network>
<followers>500</followers>
</social>
<social>
<network>Twitter</network>
<followers>500</followers>
</social>
<social>
<network>Google+</network>
<followers>500</followers>
</social>
<social>
<network>YouTube</network>
<followers>500</followers>
</social>
What I did so far and where my limited skills end.
Merging various codes into one .php gave me this:
http://img.524d.de/i/xqki8x1mwqp4.jpg
I used following code:
<?php
//The following code returns the Number of likes for any facebook page.
//Page Id of TechRecite.com. Replace it with your page.
$page_id = "fbchannel1";
$likes = 0; //Initialize the count
//Construct a Facebook URL
$json_url ='https://graph.facebook.com/'.$page_id.'';
$json = file_get_contents($json_url);
$json_output = json_decode($json);
//Extract the likes count from the JSON object
if($json_output->likes){
$likes = $json_output->likes;
}
//Printing the count
echo ''.$likes.'';
?>
<a href="https://twitter.com/twchannel1" class="twitter-follow-button" data-show-count="true" data-lang="en">@twchannel1</a><br>
YouTube
<?php
$data = file_get_contents('http://gdata.youtube.com/feeds/api/users/zeissbettervision?alt=json');
$data = json_decode($data, true);
$stats_data = $data['entry']['yt$statistics'];
echo ''.$stats_data['subscriberCount'].'';
?>
How do I get these scripts to parse their output in the XML I mentioned before?
Thank you so much in advance!