Jump to content

How do you sync PHP code with Social Media, to show 'followers'?


simona6

Recommended Posts

We are building a site for users to post articles on certain topics and we want to show their number of followers on various social media platforms.

Apart from them having the means to add it manually, there must be a method of syncing with their account, that they punch in, so that it dynamically updates our database with their number of followers.

How is it done?

Link to comment
Share on other sites

All we need to do, is assign the username the person has entered onto our website database, and compare that with Twitter - access their "amount of followers", and then update OUR system to that effect.

Same for the other SM platforms too.

Link to comment
Share on other sites

function twitter_user_info($screen_name){
 
    $data = file_get_contents("https://api.twitter.com/1.1/users/lookup.json?screen_name=" . $screen_name);
    $data = json_decode($data, true);
    //echo $data;
    return $data[0];
}
 
$twitter = twitter_user_info("test_user");
echo "Followers count: " . $twitter['followers_count'];

I read that this should work, when you replace "test_user" with the handler, but it doesn't.

Anyone got an ideas please?

Link to comment
Share on other sites

8 hours ago, simona6 said:

What about Facebook and Instagram.  Do they have similar methods?

Yes. Just remember that there are a lot of tutorials still on the web that were written in a simpler time, so if it doesn't mention having to authenticate the request it's very likely rather old and probably won't work. I can't guarantee that's the case, of course, but given the privacy concerns (or lack thereof) that have come to light recently it probably is.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.