Restricted Facebook Page Details over Graph API using PHP SDK - php

I'm trying to use Facebook's PHP SDK to get the number of likes for a fan page. This works fine for most pages, but some pages are returning false because they have age restrictions. Using the PHP SDK, how do I get the number of likes for an age restricted fan page over the graph API?
I'm currently not using an access token to read the pages. Would an app access token work? And if so how do I use an app access token with the PHP SDK.

Restricted pages can be read using the graph api but it requires a user's access token. I had tried it with an app access token which does not work.
The relevant documentation can be found here: https://developers.facebook.com/docs/reference/api/page/

You should to use Page access token. To get list of your pages with access tokens, use me/accounts method of the Graph API.

Related

Get Facebook Marketing API Access Token Using Ads PHP SDK

I was wondering how does one get access to the FB Marketing API Access Token using the Ads SDK. Currently am I manually doing this:
https://www.facebook.com/dialog/oauth?client_id=<APP_ID>&redirect_uri=
<http://yourwebsite.com/>&scope=ads_management,manage_pages,publish_actions
Which returns a code like this:
?code=<your auth code>
Then I input into the next URL provided by FB:
https://graph.facebook.com/<API_VERSION>/oauth/access_token?client_id=<APP_ID>&
redirect_uri=<http://www.yoursite.com>&client_secret=<APP_SECRET>&code=<CODE>
This gives me the access token, but am assuming there is a better way to get the access token using the Ads PHP SDK provided? I hope. If anyone can help. Please share, thanks!
You can extend an access token to be a 'long-lived' server-side token. This extension will give it a lengthy expiration. More info here: https://developers.facebook.com/docs/facebook-login/access-tokens#long-via-code
You can also authenticate via the PHP SDK as you mentioned. Get started here: https://github.com/facebook/facebook-php-ads-sdk/blob/master/DEVELOPER_GUIDE.md#authentication-

Get first 4 posts from facebook fanpage without access token

Can I fetch facebook fanpage posts with graph https://graph.facebook.com/ using php when I try curl on this I get blank/no-response
I like to avoid using fb token if possible otherwise would like to use latest php sdk
You can just use an App Access Token for this:
https://graph.facebook.com/page-id/feed?access_token=APP-ID|APP-SECRET
...or if you only want to get the posts from the Page, without the User posts:
https://graph.facebook.com/page-id/posts?access_token=APP-ID|APP-SECRET
More information: https://developers.facebook.com/docs/graph-api/reference/v2.2/page/feed

Facebook Graph API with PHP connection

i want to display facebook friends on my website and i want to use facebook graph api for that,
please
Thanks
Prakash
Facebook Graph API with PHP connection
This tutorial might help: Facebook PHP SDK
It includes example as well.
Generate an access token for yourself by going to https://developers.facebook.com/tools/explorer and then you may be able to retrieve your friends by accessing https://graph.facebook.com/_YOUR_USER_ID_/friends?access_token=xx and then the profile images can be retrieved using the following graph API call - https://graph.facebook.com/_FRIEND_PROFILE_ID_/picture?type=square
Of course, for more details, the Facebook Documentation (https://developers.facebook.com/docs/) is where you go to.

How to post to facebook wall once I've got the access token

I'm making a facebook app and have got as far as getting the user to allow my apps permissions, which then generates a code. Then using this code to get an access token. So I now have a variable in my PHP script containing the access token. Now how do I use this to post to the users wall?
The easiest way to post a message on the wall is through the graph api. You require the publish_stream permission to post status messages. You can simply do a POST with the desired message and the access token.
See the official facebook documentation for more details: http://developers.facebook.com/docs/reference/api/status/
Facebook changes their API so often, it's best to read their docs, if those are up to date...
Check in IRC #facebook as well.
But basically, you pass that token in to the API call somewhere, somehow and it's in their docs somewhere.
Unless FB has decided you don't need it or ignores it or doesn't want to allow that this week.

Accessing a pages events using facebook graph api

Just started working with the Facebook graph api and have hit abit of a wall. I want to access facebook pages by using the api /events/ however i have discovered that this requires an access token, IE a login. (at least thats how i think works)
Basically my site lists bands and events, so id like the user (band) to specify a connection to their facebook page if they have one (pageId) so i can dynamically pull the events they have posted to their facebook page.
Is this even at all possible? at the moment i am able to pull in the pages feed like /feed/ but running /events/ throws an excpetion saying it requires an access token.
Im using PHP with a fresh install of codeigniter 2.0 its also worth mentioning im using elliot haughins facebook library facebook library though this isnt essential to my project
You can register an app with facebook and it can have it's own token that you can use to access the event for pages. You can find out how to get an app token here. http://developers.facebook.com/docs/authentication/
Hope that helps.

Categories