simona6 Posted February 17, 2020 Share Posted February 17, 2020 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? Quote Link to comment https://forums.phpfreaks.com/topic/310052-how-do-you-sync-php-code-with-social-media-to-show-followers/ Share on other sites More sharing options...
chhorn Posted February 17, 2020 Share Posted February 17, 2020 Best way is tu query the APIs of the platforms if available. Quote Link to comment https://forums.phpfreaks.com/topic/310052-how-do-you-sync-php-code-with-social-media-to-show-followers/#findComment-1574375 Share on other sites More sharing options...
simona6 Posted February 17, 2020 Author Share Posted February 17, 2020 Sure - how do we find out how to get those, and how to query them, so our DB gets updated dynamically? Quote Link to comment https://forums.phpfreaks.com/topic/310052-how-do-you-sync-php-code-with-social-media-to-show-followers/#findComment-1574376 Share on other sites More sharing options...
maxxd Posted February 17, 2020 Share Posted February 17, 2020 https://developer.twitter.com/en/docs https://developers.facebook.com/ All the major social media outlets have API documentation available, and all the ones I've ever had to deal with had PHP integration libraries freely available on GitHub or their respective developer sites - Google it and you should be on your way. Quote Link to comment https://forums.phpfreaks.com/topic/310052-how-do-you-sync-php-code-with-social-media-to-show-followers/#findComment-1574381 Share on other sites More sharing options...
simona6 Posted February 17, 2020 Author Share Posted February 17, 2020 Goodness me... where does one start.............. Quote Link to comment https://forums.phpfreaks.com/topic/310052-how-do-you-sync-php-code-with-social-media-to-show-followers/#findComment-1574382 Share on other sites More sharing options...
simona6 Posted February 17, 2020 Author Share Posted February 17, 2020 https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-followers-list This is getting close to it.... Quote Link to comment https://forums.phpfreaks.com/topic/310052-how-do-you-sync-php-code-with-social-media-to-show-followers/#findComment-1574383 Share on other sites More sharing options...
requinix Posted February 17, 2020 Share Posted February 17, 2020 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. Quote Link to comment https://forums.phpfreaks.com/topic/310052-how-do-you-sync-php-code-with-social-media-to-show-followers/#findComment-1574448 Share on other sites More sharing options...
simona6 Posted February 18, 2020 Author Share Posted February 18, 2020 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. Quote Link to comment https://forums.phpfreaks.com/topic/310052-how-do-you-sync-php-code-with-social-media-to-show-followers/#findComment-1574478 Share on other sites More sharing options...
simona6 Posted February 19, 2020 Author Share Posted February 19, 2020 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? Quote Link to comment https://forums.phpfreaks.com/topic/310052-how-do-you-sync-php-code-with-social-media-to-show-followers/#findComment-1574579 Share on other sites More sharing options...
kicken Posted February 19, 2020 Share Posted February 19, 2020 https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-lookup Quote Requires authentication? Yes You have to authenticate your request, you can't just load up the URL. Quote Link to comment https://forums.phpfreaks.com/topic/310052-how-do-you-sync-php-code-with-social-media-to-show-followers/#findComment-1574582 Share on other sites More sharing options...
simona6 Posted February 19, 2020 Author Share Posted February 19, 2020 Gotcha. I've setup a Developer account and just waiting for approval now. What about Facebook and Instagram. Do they have similar methods? Quote Link to comment https://forums.phpfreaks.com/topic/310052-how-do-you-sync-php-code-with-social-media-to-show-followers/#findComment-1574583 Share on other sites More sharing options...
maxxd Posted February 20, 2020 Share Posted February 20, 2020 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. Quote Link to comment https://forums.phpfreaks.com/topic/310052-how-do-you-sync-php-code-with-social-media-to-show-followers/#findComment-1574612 Share on other sites More sharing options...
simona6 Posted February 20, 2020 Author Share Posted February 20, 2020 I see. Twitter have accepted us as Developers, so we can at least try that now! Quote Link to comment https://forums.phpfreaks.com/topic/310052-how-do-you-sync-php-code-with-social-media-to-show-followers/#findComment-1574630 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.