I'm trying to create an album on my Facebook app using the Graph API. It's quite easy to create an album for a user account. We just need to have a user access token and send a post request for
https://graph.facebook.com/USER_ID/albums
{
name :'my USER album'
}
It seems to be logical sending the same post request for app:
https://graph.facebook.com/APP_ID/albums
{
name :'my APP album'
}
However it doesn't work. I use the app token which I get from:
access token tool.
Does anybody know how can I do this?
I found a solution. It's quite wird, but what can I do.
Only a user who is an admin of the app can create new albums and photos. If you meet this criterion your app needs to request the user for one more permission: manage_pages.
After this you can request http://graph.facebook.com/ADMIN_USER_ID/accounts. There you will get an array of all pages managed by this user. Find en element which contains your APP_ID. The same element contains an access_token which is required to perform create album and upload photo actions.
Quite simple solution detailed on the facebook Authentication documentation.(Scroll down to "App Login")
You have to query this url :
https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&
grant_type=client_credentials
the response will be an access token that you can use to perform actions on behalf of you app.
Use page access token instead of user access token,for some operation we require page access token.
It looks like the new API (GraphQL 2.9 as of today) is no more able to create albums dedicated to the Application.
https://developers.facebook.com/docs/graph-api/reference/application/
I have opened a question here : Create photo albums in a Facebook app
Related
i am trying to use facebook javascript api to get the details of a public photo uploaded by a user. The photo_id is 645046238933001, and i am using this code:
FB.api('/645046238933001', function(response){...} ). the code is executed in a browser when a user is logged in to my app using facebook.
Using graph api explorer and an app access token i am able to get the photo object but with any other valid user access token (not the user uploaded the photo) facebook returns "unsupported get request..." (using graph api explorer)
what might be the problem?
thank you
That´s intentional. Even if the photo is public, you still need a User Token of the correct user to get access with the API.
The Facebook docs are a bit misleading, the info seems to be outdated because it actually would only be possible for photos on Pages:
Any valid access token for any photo with public privacy settings.
...in the next line there´s the correct info:
For any photos uploaded by someone, and any photos in which they have
been tagged - A user access token for that person with user_photos
permission
Also, even if you would get the photo of another user: It is not possible to like a post/photo on Facebook with the API.
I'm using a facebook extension in TYPO3 to pull out the facebook posts of a page. Therefor I need the accesstoken.
I googled around and found that I need a facebook app and I need to be administrator of the page.
Then I heard that I need to connet the app with the site, but how can I do this?
I also tried to get accesstoken:
https://graph.facebook.com/oauth/access_token?client_id=APP_ID&client_secret=APP_SECRET&grant_type=client_credentials
And then performing:
https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token& client_id={app-id}&client_secret={app-secret}&fb_exchange_token={short-lived-token}
... with this token but it says No user access token specified
Can someone help me step by step how to get the long lived token?
As you just want to pull, you really don't need a page access token. Until and unless you have a demographic or other restriction over your page. All the pages are Public and data over them can be easily accessed by using the App Access Token which is simply put
Your_App_ID|Your_App_Secret
first u need to get an API key from facebook, so here are the steps--->
http://www.shoutmeloud.com/how-to-acquire-your-facebook-api-key.html
& then u can access facebook API, these are docs provided by the facebook to use that API--->
https://developers.facebook.com/docs/guides/web/
This was my implementation (PHP):
$newposts = json_decode(file_get_contents("https://graph.facebook.com/YOURFBPAGE/feed&access_token=YOURAPPID|YOURAPPSECRET"));
Since I was only using this to make simple pull request of my feed posts this is the best way to do it. You don't have to deal with expiring access tokens. Just create your facebook App and get the ID and secret.
I am trying to access a public FB community page and display the images on web page, example-http://www.codeofaninja.com/2011/06/display-facebook-photos-to-your-website.html
My site is being developed in java, so I am looking for a core java solution to do something like this.
My site does not prompt for the user to login via Facebook or authenticate. I am simply trying to display all the images from my own album on my website.
I have created an FB app, and then created a community page on which I have my pictures.
I am struggling to I authenticate from the backend code of my with my app or page. My app has user_photos permission and the App Type (Apps->Your APP->Advanced->App type) is Web.
Here are the things I tried using graph API:
1) Get access token
https://graph.facebook.com/oauth/access_token?client_id=ABC&client_secret=XYZ&grant_type=client_credentials
2) Then use access token to get access to the page and its albums, but the above gives me app access_token. As mentioned on Graph API documentation for Page it requires a page acess_token, but I am not understanding how do I get the page_access_token via an app access_token with a backend application.
After Page access token is retrieved I can use the following call to retrieve all photos.
https://graph.facebook.com/PAGE_ID/photos?access_token=<page_access_token>
You can make the following Graph API call To get the page access tokens for all the Pages a particular user admin.
https://graph.facebook.com/user_id/accounts?access_token=<user_acess_token>
the app access token that you're retrieving from
https://graph.facebook.com/oauth/access_token?client_id=ABC&client_secret=XYZ&grant_type=client_credentials
can be used to access the public data on a page - you don't need a specific 'page' access token.
this page https://developers.facebook.com/tools/explorer/ is handy for testing things out - plug in the app access token and the page url to try it out
but I am not understanding how do I get the page_access_token via an app access_token with a backend application.
Not at all …
To get a page access token, you have to have a user access token with manage_pages permission first.
(If you get a long-lived user access token, and use that to get the page access token, then the latter will not expire by default.)
i am trying to catch the posts of a certain page using the open graph of facebook using https://graph.facebook.com/175119619168907/posts?access_token=access_token.
i was wondering do i have to create a new token for each user that goies to my page then he needs to add my app to his app lists? or can i create a token that does not expire and which i can use for all the users taht logs in? there is no security issue here since the user can only read posts and not write/comment.
I found out the solution that you have to create an app token using the following url:
GET https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID
&client_secret=YOUR_APP_SECRET
&grant_type=client_credentials
this token will not expire
Is it possible to get the ID (Facebook Graph API) of a user who is currently logged in, without any access tokens?
If not, then how do I get new access tokens every time a user visits my page?
You will need to init the Facebook Javascript SDK and the user will have to have authorized your app at least one time. After that when the user visits your page as long as they are logged into Facebook you'll have access to the id and can retrieve it using
FB.getLoginStatus
the response will contain the information you're looking for.
Check this blog post for more details on setting up the FB init and the initial login.
https://developers.facebook.com/blog/post/525/
You can check the facebook ID using their username
http://graph.facebook.com/radrivan
You can use the javascript sdk to get their accesstoken and let them allow your app.
https://developers.facebook.com/docs/facebook-login/login-flow-for-web/v2.2