I need to grab the latest post from a facebook like page. I'm an administrator on the page so I have the app id but reading the docs looks like I need the app secret so I can then get an access token. So I followed instructions and went to the developer app. Problem is the page doesn't show up as an app so I can't access the ifo I need
When I visit https://graph.facebook.com/MY_PAGE_ID/feed?limit=1 i just get an oauth exception saying I need an access token.
Any ideas?
Just in case anyone gets similarly confused.....Turns out I needed to create an app in order to get an access token and secret which I could then use in my url...which looks like this:
https://graph.facebook.com/my_app_id_here/feed?access_token=My_access_token_here
The feed? bit gets me the pages news feed and the access token was generated once I had created an app using my facebook account. The app id can be obtained by going to the like page and clicking on the edit tab next to about (You must be an admin of that page to see this).
Related
I'm looking for a way to be able to manage our page's Facebook tabs automatically, without needing an admin to log in. I tried using using the related app's ID and secret as suggested in this SO answer (FB docs) and that gets me access to the page and it seems all of the data on the page except tabs. When I try to access /{page-id}/tabs I get { data: [] } as the response. Page API endpoints I have tried work fine.
I have also tried /{pageId}?fields=access_token as suggested in this SO answer and it just retuned the app ID, the access token field completely absent. I tried that again using a user access token and it returned a token, but the Access Token Debugger said the token expires in one hour.
I'm trying to automate the removal and reordering of tabs, but if the user needs to log in an hour before this happens it defeats the purpose. Is there any way I can get a permanent access token for a page that will return tabs? Is there any way to accomplish this with the app id/secret access token method?
It looks like there is no way to get an access token for a page with only an App ID and secret. You have to have a user with access log in and give you their access token. However, with CBroe's helpful links I was able to get a never expiring page access token. You can see the steps I took in this answer to almost the same question.
I am trying to write a script that grabs the latest Facebook status. I get the latest status by calling https://graph.facebook.com/LIKEPAGE?fields=statuses.limit%281%29.fields%28message,updated_time%29&access_token=TOKEN
The problem is that the token expires. I read someting on Facebook about the problem. https://developers.facebook.com/roadmap/offline-access-removal/
Can a server access the page (graph.facebook) and fetch the JSON-response? Or do I have to make the user login everytime? That is an option, but I would like to avoid it if it is possible?
So, can I fetch the latest status via a PHP script without makeing the user login?
You should dynamically generate the access token. For this you should first create a Facebook App, just create it and leave it empty. From this app you will get the Fb App ID and Fb App Secret. Then using this URL:
https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=FB_APP_ID&client_secret=FB_APP_SECRET
you will get the access token.
I'm fairly new to facebook development and I still get confused about the oAuth thing.
A client of mine asked me to show the latest posts, links and statuses of his facebook page to his website.
On the a php page on his website I'm creating a url
"https://graph.facebook.com/".$clientFacebookPage."/posts?limit=1&access_token= xxx
In order to json decode it and display the info I want, but I don't know how to get an access token. I generated an access token with the graph explorer that is tied to my name as a facebook developer but that expires in 2 hours.
There are many thing that confuse me already and I hope you can point me towards a solution
I've read the documentation but everything revolves around users getting logged on your app and you app posting. So my questions are:
Do I need to create an app to do a curl (requiring special permissions) using the http://graph.facebook/xxxx url?
If so, does the adming of the facebook page need to authorize with the app?
What do I need to do next? I can create a web page using the app id and secret. Does that mean that I can retrieve the info of the facebook page? How?
I know that the page needs an auth token to curl the http://graph.facebook/xxxx page and retrieve the data needed. Where can I generate it? Does the webpage need to generate it, or do I have (as the app developer) acquire the token and write it to my php code?
If I log out of the facebook, will the program/webpage stop functioning?
I hope I didn't confuse you.
Thank you.
The basic process for obtaining an access token for a Page is as follows:
1. Get a user access token for a User who is an admin of the Page
2. Using this User token, request graph.facebook.com/me/accounts and look for the correct Page ID in the list returned.
3. Grab the associated Page token from that ID
4. Use it to do Page stuff.
There is a newly launched Facebook docs guide which shows you how to obtain one of these access tokens in a step-by-step fashion:
https://developers.facebook.com/docs/howtos/login/login-as-page/
Hopefully that guide should help you.
I will also answer your questions in order:
Yes, you will need an app in order to generate access tokens to make API queries
Yes
This is in the guide linked above (start at the Getting Started if you need to create a way to get a User Access Token also)
Again, see the guide above
Yes, but you should follow the steps in this guide to generate a long-lived access token. Once you do that, any Page token you retrieve will last forever.
A while back I created an app ID on facebook and added the appropriate meta data to a website. I now want to continue adding facebook-related features to the site, but it seems the app is not related to my account afterall.
I must have created it under a different account or something, but how can I find who the owner is based on an App ID? I have existing likes, so I don't really want to change the App ID. I don't see any way in the UI, and I do not see the app when I go to the Developer app. Is there a way to do it using the Graph API?
If you have access to the app id and the app secret but no access to the app within Facebook it is possible to discover the creator_uid and from there the email address of the app owner using the graph api.
First get an app access token:
https://graph.facebook.com/oauth/access_token?client_id={APP_ID}&client_secret={APP_SECRET}&grant_type=client_credentials
With this you can get the creator_uid:
https://graph.facebook.com/{APP_ID}?access_token={APP_ACCESS_TOKEN}&fields=creator_uid
Using the app token you will then get the email address when looking up the creator_uid in the graph api:
https://graph.facebook.com/{creator_uid}?access_token={APP_ACCESS_TOKEN}
EDIT (Jan 2013)
Looks like Facebook have removed app profile pages so that method no longer works.
Option 1
You could return the app object, which stores all the populated information about the app by requesting:
https://graph.facebook.com/xxxxxxxxxxxxxxx
Option 2 (This method no longer works)
Or, you could visit the app's profile page and contact the developer directly using the 'contact developer' link:
http://www.facebook.com/apps/application.php?id=xxxxxxxxxxxxxx
(you'll need to replace xxxxxxxxxxx with your app id)
I got this working. If you have both app id and app secret then you can try below steps to get the owner details.
Get the access token using id and secret of the facebook app.
https://graph.facebook.com/oauth/access_token?client_id={APP_ID}&client_secret={APP_SECRET}&grant_type=client_credentials
Using the access token you can call the below API to get a list of administrators of the app.
https://graph.facebook.com/{APP_ID}?fields=id,name,roles&access_token={ACCESS_TOKEN}
Retrieve the owner profile details by,
https://www.facebook.com/{USER_ID}
I have a similar problem, in that I have the id and the secret but no access to the app within facebook.
I haven't found a way to see who owns does have access to the app. But I have found a way to contact a dev
First get the app access token.
https://graph.facebook.com/oauth/access_token?client_id={APP_ID}&client_secret={APP_SECRET}&grant_type=client_credentials
Then get the address:
https://graph.facebook.com/{APP_ID}?access_token={APP_ACCESS_TOKEN}
I am a bit confused about the facebook graph api and access tokens.
I have created a facebook user and a facebook page. Now I want to write an application that lets the user post a message on the pages wall/feed. As far as I understand it right now I need an access token of the user to post a message to the pages wall. To create that I need an app id and app secret. But there is no app, there is just the page and the feed. Do I have to create an app? And how would I connect the app to the page without creating a new tab on that page?
In order to do anything whilst acting as a user, you're going to need an App and the correct permissions from the User. Read more about Authentication here