Getting page photos with Facebook Graph API - facebook

I'm using Facebook Graph API here: http://crackit.seegermattijs.be/wedstrijd.html I'm trying to get access with the following url: https://graph.facebook.com/10150146071791729/photos
This was working for 2 weeks but all of a sudden I always get following error
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException",
"code": 104
}
}
Is there anyone who can figure this out?
Kind regards
Seeger

Try this ....
https://developers.facebook.com/tools/explorer/?method=GET&path=10150146071791729%2Fphotos
I'm using 'Graph API Explorer', that's no problem.
"message": "An access token is required to request this resource."
This message means "You're not logged in with Facebook"

You need to renew your Access Token.
Ensure that you are an Admin of the Facebook Page.
go to :
http://developers.facebook.com/tools/explorer
In the API Navigator, you can see "/me" will bring up the basic information of yourself.
Try typing in "/me/accounts" to see if you can see anything. It should give you an error.
Click on "Get Access Token"
a window will pop-up. Navigate to "Extended Permissions"
Select "manage_pages"
Click "Get Access Token"
Now try "/me/accounts" again. You should see a list of Groups inside the viewing window.
Select the Page you want, and click on the "id" field
Next, on the left window, you can see "Node: " and a + sign. Click on the + sign to see what are the options you have.
Click on the + sign and scroll down to "connections" and select "Albums"
The child-level, select "Photos"
The "Photos" child-level, select "source"
Now click "Submit" on the right hand side. You will see a JSON returned with the url of all the photos in your Facebook Page.
Copy the URL - https://graph.facebook.com/?fields=albums.fields(photos.fields(source)) and plug it into your browser. You should see a JSON of all your photos.

Related

Permission issue when publish comment with Facebook Graph API v2.12

I am testing the facebook graph API comments
https://developers.facebook.com/docs/graph-api/reference/v2.12/object/comments
I checked my permission for the access token it contains the permission, which required by API. see the screenshot
I test my object-id (1797963943566411_1975256375837166) which is correct see me screenshot
Change the request method to POST and adding post data {"message": "haha"}
I get the error message shows:
"(#3) Publishing comments through the API is only available for page access tokens" see my screenshot
As you can see the first step checking, I have all the permission that the
API required.
Can any one see any sort of error in this process?
Try another way still not work.
I have a user who post a photo on his own facebook page.
I logged in with this user and give this user all permissions see the screenshot
enter image description here
call /me/accounts to get page access token
enter image description here
copy the page access token into the Graph API Explorer's access token field
call
GET: 1797963943566411_1975256375837166/likes
is working fine
But call POST: 1797963943566411_1975256375837166/likes
Get error response:
{
"error": {
"message": "(#200) Permissions error",
"type": "OAuthException",
"code": 200,
"fbtrace_id": "GtEaBfyXrUD"
}
}
The reason is Facebook changed the API behaviour. We are no longer to use api to like any POST on our time line. API can only like or comments on facebook page. Sad face !!!!

graph.facebook.com/username does not work

I tried to get user detail using https://graph.facebook.com/username . But it throws an error
"error": {
"message": "(#803) Cannot query users by their username (ramesh.randika.56)",
"type": "OAuthException",
"code": 803
}
does anybody have a solution for this problem.
graph.facebook.com/{Username} is not avaiable now but lookup-id.com still can find your facebook ID, facebook group ID and facebook page ID
"View page source" Option in every web browser will help you.
Follow this-
Open the timeline of that person/FB account.
Right-click anywhere on the web-page->View page Source-> wait 1 or 2 seconds to load the new page.
Press Ctrl+f (used to find any string,word in the page) then type " profile_id= " (without quotes).
Copy the long number after " = ", .
Conclusion : Using the "username" doesn't work anymore (Updated till Oct 2018),profile_id is the thing u needed instead.
The username field was removed with the introduction of the Graph API v2.0.
See
https://developers.facebook.com/docs/apps/changelog#v2_0
/me/username is no longer available.

get conversations of FB page via open graph api

I've registered an Facebook-App and created a token with all permissions I need. Among them
manage_pages
read_mailbox
read_page_mailbox
Now I want to use the Facebook open graph API to read some data from my own FB-page. I want to read the private messages that the page received and that I sent to some of the fans on my pages behalf.
I know I can get all information by sending a http-request like this:
https://graph.facebook.com/{page-id}/{object}?access_token={token}
where {something} are placeholders for actual values. To give an working example, I can read the postings that appeared on my page by sending this request:
https://graph.facebook.com/141928949155955/posts?access_token={my secret token}
As I said, this works fine, since more than two years. (I just need to update the token from time to time)
But now I want to read the private conversations between the page and it's fans. I want to extract all conversations and insert them into a spreadsheet. I want to do it once, and maybe in 1 or 2 years again. I could extract them manually from the browser window by copy and paste for each conversation, but since there are so many conversations I think it costs less time to let a program do it for me.
If I understand Facebooks Documentation correct, then the keyword that I must use must be conversations. But I get this:
https://graph.facebook.com/141928949155955/conversations?access_token={secret token}
{
"error": {
"message": "(#210) Subject must be a page.",
"type": "OAuthException",
"code": 210
}
}
But 141928949155955 is a page. I don't know what I'm doing wrong. What is the correct request that I must send to receive a pages private conversations?
EDIT (June 16th):
I can read my personal conversations with this request:
https://graph.facebook.com/me/conversations?access_token={secret token}
But I don't want to read the conversations that I made as a person. I need those of one of my pages.
I found the solution for my problem. (Thanks kush, your answer helped a lot, but I want to add some more information)
My problem was that I misunderstood the error message "Subject must be a page." I thought that "Subject" refers to a part in the query string. But it refers to the token! A message like "Token must be a Page Access Token" would have saved me WEEKS of needless searching over a period of more than two years! How can you use a term like "Subject" when you nowhere define what "Subject" is?
So it was not the query string that was wrong. It was the type of the token!
Now here is the complete procedure to solve the problem (get a Page Access Token)
SOLUTION
Step 1
Get a User Access Token for your App that you can use later to get a Page Access Token
1.1 Go to Graph API Explorer https://developers.facebook.com/tools/explorer/
1.2 Select your App from the "Application:" drop down menu.
1.3 Click "Get Access Token".
1.4 From the tab "Extended Permissions" select "manage_pages".
Additionally select all permissions you need for the Page Access Token. (Although now you don't create a Page Access Token, just a User Access Token)
1.5 Click "Get Access Token".
1.6 Grant the permissions by clicking "OK".
In the field "Access Token:" you find now a Token that is an User Access Token. It is not a Page Access Token! This Token has all permissions you need to manage your page (including the permission "manage_pages"), but you can't use it to manage pages since it is the wrong type of token. You need this token only for one reason: To create a new token.
Step 2
Use the User Access Token you just got to create a Page Access Token
2.1 Enter "me/accounts" in the query field
2.2 Click "Submit"
You get a list of your pages, each with an "access_token" (which is now a Page Access Token). Each of this tokens did inherit the permissions from the User Access Token you used when you called "me/accounts".
This Page Access Token expires after one hour.
supplement
If you want a Page Access Token that never expires, do it this way:
A.1 Go to https://developers.facebook.com
A.2 From the drop down menu "Apps" select the App you want to use.
A.3 Click on "show" in the field "App Secret" (you need to enter your Facebook Password)
A.4 Open a new tab in your browser and there execute steps 1.1 to 1.6 from above to generate a short-lived User Access Token
A.5 Open a third Tab in your browser and there enter this string into the address field of your browser:
https://graph.facebook.com/v2.0/oauth/access_token?grant_type=fb_exchange_token&client_id={app-id}&client_secret={app-secret}&fb_exchange_token={short-lived-token} (do not press enter!) If this strings disappears when switching from one browser tab to another use any text editor to assemble the string and copy it later into the address field.
A.6 In this string replace {app-id} and {app-secret} by the values from the browser tab that still shows your Apps data.
A.7 Replace {short-lived-token} with the User Access Token you find in the field "Access Token:" from the Graph API Explorer.
(After this step there are no more curly brackets in the address string)
A.8 send this request (press Enter now)
Your browser window now shows a String with the fields "access_token" and "expires", separated by an ampersand ("&") which is not part of the token. This Token is a long lived User Access Token that will expire in two month.
A.9 Execute Steps 2.1 and 2.2 using the "access_token" from step A.8
The result is a Page Access Tokes with all permissions you selected in Step 1.4 and that never will expire.
Good luck!
Using page access token should help since you are reading from the page ..
Graph api node: GET me/accounts
me/accounts would give you the pages you are admin for and use access token coming in the page info dictionary.
you should get the following data from me/accounts
{
"data": [
{
"category": "Product/service",
"name": "Sample Page",
"access_token": "{page-access-token}",
"id": "1234567890",
"perms": [
"ADMINISTER",
"EDIT_PROFILE",
"CREATE_CONTENT",
"MODERATE_CONTENT",
"CREATE_ADS",
"BASIC_ADMIN"
]
},
}
Use page-access-token to access data from page as the page admin and thou shall receive data :) let me know if this works :)
A successful authorization would return an access token to your app, which you can then use to perform actions to the Facebook API. The error message displayed means you do not have a valid access token which means you probably did not authenticate the app correctly. I would put some logging on the onFacebookError and onError methods to see what the problem is.
Request Permission At Login time So Its Authentication Error
Permission List
https://developers.facebook.com/docs/facebook-login/access-tokens/
Set Permission Reference
https://developers.facebook.com/docs/android/login-with-facebook#permissions

Facebook Graph API and Insights not working

I simply want to pull insight data for my company utilizing the Facebook Graph API. I am testing using https://developers.facebook.com/tools/explorer.
When I enter https://graph.facebook.com/MY_ID/insights? and an Access Token I would expect to see JSON data with such data as Page_Views. However I only see this:
{
"data": [
],
"paging": {
"previous": "https://graph.facebook.com/MY_ID/insights?format=json&since=1337268417&until=1337527617",
"next": "https://graph.facebook.com/MY_ID/insights?format=json&since=1337786817&until=1338046017"
}
}
Any suggestions on the URL or perhaps I shouldn't be using Graph API to view Page_Views?
From the Page object documentation, for the insights connection:
Permissions: A valid access_token with read_insights permission for a user
authorized to view the Page's insights
In the explorer click the Get Access Token button, change to the "Extended Permissions" tab and check the "read_insights" box, then click the button and try again.
For anyone else who might run into this issue that wants to view a 'Page' nstead of a user in say v2.4 you might need to use 'Get Page Token' in the 'Get Token' field otherwise you could be seeing what ToddN saw

Cannot publish an action required to submit it to create an FB app

I have created an facebook app, took built-in action (read) and object (article), also back at my web site properly inserted meta og: tags, only thing left to do is to publish at leaste one action to my timeline and submit my action, but every time I try "https://graph.facebook.com/me/namespace:read?article=correctURL&access_token="access token copied from the "Get code" dialog at Open graph settings", and it returns me this message
{
"error": {
"message": "Unknown path components: /appnamespace:read",
"type": "OAuthException",
"code": 2500
}
}
Is this a facebook bug at the moment, or am I just doing something wrong here? Is there any precise way to deal with this?
According with the "Get code" dialog at Open graph settings, the uri should be
https://graph.facebook.com/me/news.reads?article="...."&access_token="..."
The namespace should be used only with custom actions.