I want Facebook page likes counter to be visible on my WordPress website.
Until around a week ago (mid June 2015) the following PHP code did the job:
<?php
...
$params = array(
'sslverify' => false,
'timeout' => 60
);
$api_url = 'https://graph.facebook.com/';
$this->connection = wp_remote_get( $api_url . $facebook_page_id, $params );
...
/* if error then use cached data */
...
?>
but something seems to have changed, as it does not work any more.
I tried querying Facebook Graph API with “https://graph.facebook.com/page_id“, but it returns an authentication error:
{"error":{"message":"An access token is required to request this resource.","type":"OAuthException","code":104}}
As far as I understand, there is no need in access token for public data.
How do I resolve the issue?
You may need to generate a token for your application/code to use.
https://developers.facebook.com/docs/facebook-login/access-tokens#apptokens . funny if your code worked this long without one. You may have had a plugin or something that generated one for you, but it has expired (access tokens may need to be renewed every 90 days or so)
edit: this is a similar question How to create a Facebook Like Counter for a page on my website?