Jump to content
simona6

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

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?

Share this post


Link to post
Share on other sites

Sure - how do we find out how to get those, and how to query them, so our DB gets updated dynamically?

Share this post


Link to post
Share on other sites

Goodness me... where does one start..............

Share this post


Link to post
Share on other sites

Are you sure you need to do this from PHP? There should be a client-side API that embeds some Twitter information if you give it a username.

Share this post


Link to post
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.

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

Gotcha.  I've setup a Developer account and just waiting for approval now.
What about Facebook and Instagram.  Do they have similar methods?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

I see.  Twitter have accepted us as Developers, so we can at least try that now!

Share this post


Link to post
Share on other sites

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.