Is it possible to read the shop section from a facebook page?
I am trying to write an app to consume data from a facebook page.
I have seen references to a products field and a product_catalogs edge to be read in the page API reference. But calls to these in API Explorer have returned just the page ID and an empty data list respectively. Like so:
GET /v2.8/{page-id}?fields=products HTTP/1.1
Host: graph.facebook.com
result: {"id": <page_id>}
GET /v2.8/{page-id}/product_catalogs HTTP/1.1
Host: graph.facebook.com
result: {"data": []}
I have added multiple products to page's store. What should I be doing to access this data?
EDIT: I have seen at least one answer that sugests this is not presently possible, but it's talking about the shop section, I am hoping alternative paths will allow access to this data.
Related
I have an API for my backend which gives some JSON data in response. React Admin allow data to be shown using a DATA provider. I have tried all the data provider but none of them give me the results.
I have this API Method:
GET http://localhost:8081/customer/status/{phone_no}
which gives response as :
[
{
"mobile_number": "98160******",
"status": true
}
]
So here I want to get this data in my list view and show it on the dashboard. Is there any way to do this. I have also used the jsonDataProvider. It is not also working.
I need this to be fixed very soon. If someone know how to do that pls ping.
What error is it giving you? Use the developer tools to see the errors.
Most of the time, it is probably that you need to add Content-Range header to your API:
See below documentation from the Data Providers section:
Note: The simple REST client expects the API to include a Content-Range header in the response to getList calls. The value must be the total number of resources in the collection. This allows react-admin to know how many pages of resources there are in total, and build the pagination controls.
Content-Range: posts 0-24/319
If your API is on another domain as the JS code, you’ll need to whitelist this header with an Access-Control-Expose-Headers CORS header.
Access-Control-Expose-Headers: Content-Range
Thanks
Assume we have an api - /student/getStudentDetails/{id} which returns a JSON response containing the succeeding internal rest api (/student/getAdvancedStudentDetails/{id}).
{
id:123,
name:Alex,
nextapi:/student/getAdvancedStudentDetails/123
}
Here when we get the response from first api - /student/getStudentDetails, we need to process the JSON response and take out the second api from the first api and call it.
Any suggestions?
Your first response for first api "GET student details" only returns high level details of student and one of field "nextapi" in response has URL to GET more details about student.
In Your first response "nextapi" is customer field defined by you and it only has
URL without host and port details of sever. So Consumer of api, will have to parse First response. Create full http url and call the next api to get further details of student. It will not happen automatically.
eg http://localhost:8080/student/getAdvancedStudentDetails/123
{
id:123,
name:Alex,
nextapi:/student/getAdvancedStudentDetails/123
}
Note :
If your response had full http url for get advance details of student and if api was not secure api. Then if you view first Json, it might give you link for next api, which you can click and see advance details. You can give it try.
I'm developing a web app that uses FB data for some FB posts. I have a bunch of post ids and am fetching the data related to them using batched requests. Then am showing a summary of each post (number of comments, shares, likes) and link to the actual FB page (https://www.facebook.com/). But clicking on the link shows a 404 page on FB!!
Example, the node_id, '69983322463_10152179775342464' will return data in the graph explorer. But when you access https://www.facebook.com/69983322463_10152179775342464 it returns 404!
In case my question is not clear:
GET https://graph.facebook.com/69983322463_10152179775342464?access_token={a valid access token} returns data.
But GET https://www.facebook.com/69983322463_10152179775342464 (with or without an access_token param) returns a 404
Is there some field in the API response that signifies that the page does not exist anymore?
Thanks,
mano
This is because not every post is public. Only publicly available posts can be accessed directly.
For rest you need a valid access token to GET its details. When you tried the post id in graph api explorer it showed the result since an access token was applied.
So, you simply use a valid access token, may be any app access token (app_id|app_secret)- that never expires, and make the /GET request.
Eg: \GET /69983322463_10152179775342464?access_token={app-access-token}
In my index page, I have this link for me to auth with the facebook.
Test
Inside my TestServlet, it will auth and get the access token for me to query the graph api. I will query and store the info into a list of 200 results. The results are forward to my jsp page (test.jsp).
Inside my test.jsp:
URL will show http://xxx.herokuapp.com/test?code=xxx
As I don't wish to display all 200 results at the same time, I only load 20 results at a time. I have a link to the next page <a href='/test?page=${page+1}&code=${code}'>Next Page</a> where the page is the current page number 1 and code is the code on the url.
However, I will hit this error when I clicked the 'Next Page' link:
java.io.IOException: Server returned HTTP response code: 400 for URL: https://graph.facebook.com/oauth/access_token?client_id=xxx&redirect_uri=http://xxx.herokuapp.com/test&client_secret=xxx&code=xxx
Does the problem lies in encoding issue? If so, how should I encode the code in the url and where should I encode it? Inside my jsp page or servlet? Thanks.
Looks like you are trying to get access_token again using the same "code" in your "next page" link. And Facebook is returning 400 bad request error. The "code" returned by facebook is supposed to be used just once to get the access_token. And once you have access token, use that for all further Graph API calls.
If you are using sessions, you can store the access_token in session and use that for Graph API calls. Otherwise, you can pass the access_token (instead of code) in the next page link:
<a href='/test?page=${page+1}&access_token=${access_token}'>Next Page</a>
I'm trying to post a message using the Graph API and a C++ program. I have tried three different methods:
GET with a URL like https://graph.facebook.com/USER_ID/feed?access_token=TOKEN&message=Hello
POST and X-WWW_FORM
POST and FORM-data
In the case 1, I receive the complete list of messages as an answer, but the message doesn't add to the feed.
In the case 2 and 3, I receive an error 403 as the response.
USER_ID and TOKEN are correct and my application has the right permissions. I have reached posting an image to an album with the same application, but it's impossible for me right now to publish messages. Why?
The first method won't work because you need to issue an HTTP POST to that endpoint to publish a new feed story, as a commodity facebook provides the "method=post" GET parameter to "fake" a post, this will work
https://graph.facebook.com/USER_ID/feed?access_token=TOKEN&message=Hello&method=post
and as response you'll get the id of the new post
{
"id": "499801468_1001264776039"
}
Here you can find more details on publishing with the Graph API http://developers.facebook.com/docs/reference/api/#publishing