I've successfully authenticated a user using FB and am trying to use the graph API to access their posts. However, I'm only able to access the email field and no posts field is returned at all.
Relevant Code:
FB.api(
'/me',
'GET',
{"fields":"email,posts"},
function(response) {
console.log("Succes: ",response);
}
);
Response:
Success: { email: 'example#email', id: 'example_id' }
However the equivalent code on the graph API explorer returns
{ posts: {example_posts}, email: 'example#email', id: 'example_id' }
I'm not receiving any errors, simply no posts response. The same thing happens with fields such as feed and albums.
Something else worth noting is that when I add a field such as thisIsNotAField the API returns an error. Why is it silently failing for certain fields?
Related
I saw this, which doesn't work and this, but the Graph API Documentation says:
/{page-id}/tagged shows the posts that this page was tagged in and the
'posts to page'
So that would lend me to think that any public posts that tag a particular page should show up as a response to this API call:
FB.api(
'/{page-id}/tagged',
{
access_token : "{fake-access-token}",
limit: 10
},
function(response) {
console.log(response);
}
);
(switching out the placeholders for actual data, of course)
But only the 'posts to page' are showing up, not the posts tagged by other users.
I'd be very grateful for some insite.
here cover photos is public album.and acess token is valid. but response returns an empty array.
FB.api(
{
method: 'fql.query',
query: 'SELECT object_id FROM album WHERE owner = me() AND name="Cover Photos"',
access_token: $scope.getCookie("access_token"),
},
function(response)
{
console.log(response);
}
);
According to the FB docs the query should work if you pass a valid Access Token and your album is public.
See https://developers.facebook.com/docs/reference/fql/album/#permissions
I tried this with my user, and the query itself seems fine. I think you have a problem in your JS code. The method parameter should be one of the following: GET, POST, DELETE according to https://developers.facebook.com/docs/javascript/reference/FB.api/ The method "fql.query" is deprecated. Use the Graph API endpoint /fql instead with method GET.
See the answer here to solve your problem: Using facebook javascript sdk to process fql query
The facebook docs here say "it is the Developers' responsibility to delete a Request once it has been accepted". As far as I understand, when someone sends a request to multiple users on facebook like this:
function sendRequestViaMultiFriendSelector() {
FB.ui({method: 'apprequests',
message: 'test message'
}, requestCallback);
}
only one request_id is returned via requestCallback() function.
Then, if I delete the request when someone accepts it, how would other users accept the deleted request?
when user comes following the app request, you can get request id's using
$_GET['request_ids']
then retrieve all the request ids with which you can call graph api to delete the corresponding requests like below:
if(isset($_GET['request_ids']))
{
$request_ids = $_GET['request_ids'];
}
$request_ids = explode(",", $request_ids);
foreach($request_ids as $request_id)
{
$full_request_id = $request_id."_".$fbid; //$fbid is current user facebook id
$facebook->api("$full_request_id","DELETE");
}
Check out the Request ID Format section of the FB request overview page.
The actual graph path for a request actually sent to specific user is "request-id"_"recipient-user-id".
you can access to facebook on mobile mode (m.faceook.com)
1-access the invitation panel
2-display all the invitations
3-open console mode in chrome
4-activate jquery by cpying and pasting all the jquery.min code into console
and excecute this script :
$("._54k8._56bs._56bt").trigger("click");
that will cancel or the invitation sent
I've been banging my head over this for hours now... and can't seem to be able to remove a facebook page tab via api. The access token used has all of the following permissions "offline_access,publish_stream,manage_pages,publish_actions"
I've tried to make a call
https://graph.facebook.com/[page id]/tabs/app_[app_id]?method=delete&access_token=[access token]
the response is
{
"error": {
"message": "(#210) Subject must be a page.",
"type": "OAuthException",
"code": 210
}
}
if i use the the facebook graph explorer
http://developers.facebook.com/tools/explorer
the response is the tab object json... doesn't remove
if i do javascript api call
FB.api(**pageid/tabs/app_1234**, 'delete', {access_token: **My Access tocken**} ,function(response) {
alert(response);
});
the response is (#210) Subject must be a page.
I've read that if you include the full pagid/tabs/tabid then it becomes /paigeid/tabs/pagaid/tabs/tabid so i've tried
FB.api(**app_1234**, 'delete', {access_token: **My Access tocken**} ,function(response) {
alert(response);
});
the response is
(#803) Some of the aliases you requested do not exist: app_XXXXXXXXXXXX
if i use the C# facebook client
fc.Delete( "pageid/tabs/tabid")
the result is again
(#210) Subject must be a page.
The error message seems to be confusing. I have also come across this problem in past.
You are not using the correct access_token. Use access_token for page.
I am getting latest apprequest like this:
FB.api('/me/apprequests', function(response){
if (response.data[0]) {
// code here
};
How to delete apprequest using the same graph api method , I know this is possible with request containing access_token ... but in this case I am caching html and didn't know how
Thanks
Please use the following code (PHP):
file_get_contents('https://graph.facebook.com/'.$rid.'?access_token='.$token.'&method=DELETE') == "true";
// $rid: Request Id
// $token: Access Token
// The response is generally just the text "true"