-1

I wanted to display the share count of the articles on my blog (wordpress) to the readers. So I decided to call the api directly:

$fb_call = "https://graph.facebook.com/fql?q=SELECT%20share_count,%20total_count%20FROM%20link_stat%20WHERE%20url='".$url."'" ;
$response = wp_remote_request ( $fb_call  ) ;

This worked fine , when I test it myself. But at times, there are 100's of readers trying to access different posts at the same time, which results in an error - application request limit reached. The current limit seems to be 600 calls per 600 seconds, per token & per IP. It could be happening because the graph api is treating all these requests as if coming from the same user. So i need to add in an access token in the call. How do I generate the token without any login details server side, as the articles are shared using client side scripts, which I am not supposed to change. PHP SDK has a generate function, but I believe the user has to be logged in using that as well. Thanks for the help, and I apologize if the question is mundane/not organized.

1 Answer 1

0

You don´t need to "add a Token", you need to reduce the amount of API calls. You can´t just generate Tokens on the server anyway - except for an App Token, but you would need to create a separate App for that.

Anyway, the solution is much easier: You need to cache the results on your server - don´t use the same API call for every single user. It just does not scale. Also, it will make your Page faster - because every API call takes time. Last but not least: FQL is deprecated, it will stop working for all Apps very soon (August 7, 2016). You need to use the Graph API.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.