Facebook/Unity OpenGraph: Object with ID ' ' cannot be retrieved - facebook

I am currently trying to get Facebook to send an Open Graph object from within my Unity game however something weird is happening. I have the object set up within the Open Graph settings page, and I have done all of the set up required to get the actual object ID and everything. The image is hosted, the POST object data changed etc. The function I am calling contains the following:
FB.AppRequest(
message: "I sent you a life!",
actionType: Facebook.OGActionType.Send,
objectId: livesIdValue*,
filters: null,
excludeIds: null,
maxRecipients: null,
data: "",
title: "Send a life to your friends",
callback: sendLifeCallback
);
*livesIdValue is set to the ID that was returned from the Graph API Explorer.
The strange thing about this is, on one Facebook account, this works completely fine, and will show the Friend Picker dialog window thing. When I try it with a second Facebook account though, I get the error message:
"Object with ID 'value that is stored in livesIdValue' cannot be retrieved.
Has anybody run into this problem? I'm really not sure what could be causing this problem to only show up on one account but not the other.

Related

How to obtain the live video id of a facebook live video?

I am trying to access the live views count of a live video that is live through a Facebook Page. I am using the ID that I am obtaining from the API request {page-id}/videos/uploaded When I am using that video id and making a GET request of {video-id}?fields='live_views its showing error code of 100 with the message as:
(#100) Tried accessing nonexisting field (live_views) on node type (Video)
I have the following permissions:
'manage_pages', 'publish_pages', 'business_management', 'read_insights', 'user_videos'
I am making the GET request using user_access_token.
I am using Graph API Version 2.8.
Please let me know if I am using the wrong ID. IF yes, then how can i get the live_video_id of a live video posted in page?
To get the live views count of a video a fan page, you need:
An app created at facebook developer
A user access token (for testing, e.g. by calling https://developers.facebook.com/tools/accesstoken/)
The fan page id
With this you can call graph API in the following format:
https://graph.facebook.com/v2.8/<fan_page_id>/live_videos?access_token=<access_token>?fields=live_views
Of course, you may add more elements in fields parameter if you need more information. Here Facebook's Graph API explorer helps: https://developers.facebook.com/tools/explorer
When you add status to fields parameter, "LIVE" means, it's currently live, "VOD" means it has already finished.
If you try to implement a WebHook for it, let me now if it works. Thanks.
To get live views you need to call the api with the live video id, which you get from calling, page id can initially be either the page-id or name
"https://graph.facebook.com/v10.0/${page_id}/live_videos?access_token=${access_token}
Sample response:
{
"title": "hello world 2",
"status": "LIVE",
"embed_html": "...,
"id": "123123" // this is the live video id
},
After you have retrieved the live video id you can call this endpoint to get the live_views edge
https://graph.facebook.com/v10.0/${live_id}fields=live_views&access_token=${access_token}
sample response:
{
"live_views": 1,
"id": "123123"
}
Docs for endpoint 1: https://developers.facebook.com/docs/graph-api/reference/live-video/
Docs for endpoint 2: https://developers.facebook.com/docs/graph-api/reference/live-video/reactions#Reading
However I understand the confusion since live_views is not listed under the second endpoint as a reaction nor even is it a reaction, so either it a mistake in facebook docs or a mistake in the graph API, either the solution provided works.
Yes you do need to go through an app review to get the permission for tracking streams

How to use apprequest for send or askfor using OpenGraph API?

I am using Facebook Unity SDK to implement a sample gift module in my game.I am using the method:
**public static void AppRequest(
string message,
OGActionType actionType,
*string objectId*,
string[] to,
string data = "",
string title = "",
FacebookDelegate callback = null)**
Ref: https://developers.facebook.com/docs/games/requests/v2.2
AS the OGAction type refres to the action like askfor or send,the next arguement is object_id which i unable to get properly.
Can anyone tell do the object will be created in the app itself or it must be created in the opengraph section of my app registerd on facebook?Do i need my own sever for this?
I just need to send an item and and recieve it at the reciever's end.Please tell me where i am wrong or what i should i do to get it properly?
This is what I did:
1- On the "Tools & Support" section in the Developers' page, open "Object Browser".
2- Set the "App" and "Object Owner" section to your App.
3- Click "New Object".
4- A new object will be created and you can copy its id in the AppRequest parameters.
I don't know if there is an easier or better way to do it but, so far, I have been getting requests without issues.
Cheers!

400 Bad Request when implementing custom friend selector

I'm trying to implement a custom multiple friend selector to invite users to my game. I get the list of users calling the Graph API call InvitableFriends, and create a UI for it.
After the user selects the corresponding users, I get all the invitation tokens of the users, and make a call to an App Request as follows:
public void InviteFriends(string message, string title, FacebookDelegate callback, string[] to = null, string data = "")
{
if (FB.IsLoggedIn)
{
FB.AppRequest (message,
to,
"",
null,
null,
data,
title,
callback);
}
}
But when the call is made, I'm getting the following error:
400 Bad Request
UnityEngine.Debug:LogError(Object)
FbDebug:Error(String)
Facebook.FallbackData:JSFallback(String)
Facebook.AsyncRequestDialogPost:CallbackWithErrorHandling(FBResult)
Facebook.<Start>c__Iterator0:MoveNext()
My callback function is never called, so I can't see what the error is.
I'm using Unity 4.3 & Facebook SDK 5.1
Thanks for your help!
EDIT: I'm pretty confident that the issue is that in the TO parameter I'm passing the invite tokens that the Invitable Graph call is giving me, AND NOT THE Ids.
I tested the InteractiveConsole.cs example of friendsmash with the invitable token and it also failed. How can I get the ids of the invitable friends?
just check the url request. It may be some thing wrong with it.
or
go to https://developers.facebook.com/apps/{app-id}/app-details/
in "app Info" section, choose the proper category and sub category.
I had a similar issue.. Figured out that FB.init() has to be called before using the invitable api. Without it you would get a "400 Bad Request"
I was keeping the old access token in playerprefs and just checking it again for validity and not actually initialising FB to save load time. But eventually I had to do FB.init()

How to create a custom poll on facebook via open graph?

I wanto to create on my facebook page (facebook.com/genericco) a custom poll, in it I wanna create funny polls people can vote on (mainly yes or no answers) and I'd like to post on the voter's wall the action (john doe voted yes on Genericco's poll: Do you think chicken-fish should stop smoking for health issues?).
So I could not do that just using graph API and reading my own questions...so I decided to use the open graph! I created an action called vote with the custom property answer as a boolean...
I've also created the object poll with image,question, title, description and the custom property question...
I've also populated with custom data in the aggregations part.
Then i used Putty program to run the code and be able to submit my custom action for approval...
My question now is...How do I use it? How do I put this together to achieve the objectives I've proposed on the top of this question?
can anyone shed a light?
So...I managed to build the customized poll app with Open Graph in facebook. its going well...but its not 100% yet. let me tell you guys why:
1 - So I managed to understand how to creat an action, I called it "Vote", it is connected with the Object type "Poll" I created; The action "Vote" has 2 custom properties: "Answer" wich is a String and "Name" wich is also a String;
2 - Then I created the object "Poll" and I filled it with sample data and stuff and also I created the custom property "Question";
3 - Then I created the aggregation "Enquete Ociosidade" (roughly translating would mean sloth poll) and the data is displays is the action "vote" and in the Caption I used something like this {poll.question}{name} thinks {answer};
Then to make it work I had to send a sample of the action to facebook somehow, I had no idea how to do this so I used Putty and simply pasted the code facebook provides for that; It worked;
Then comes the hard part, how would my front-end app send those info to facebook so I could register the action? Well I'm glad you asked!
I tryed till it worked...YOUR APP MUST HAVE PUBLISHING_ACTIONS PERMISSION THIS IS VERY IMPORTANT!
so...this is the code I got working:
FB.api('/me', function(response) {
//alert(response.name);
FB.api('/me/genericco:votar_poll&enquete=http://www.limonadaweb.com.br/genericco/poll_data.php&resposta='+resposta+'&nome='+response.name+'&access_token='+_token+'' ,'post', function(resp) {
if (!resp || resp.error) {
alert('Error occured '+resp.error.message);
//mostrar caixa de diálogo que algum erro ocorreu;
} else {
alert('Post was successful! Action ID: ' + resp.id);
//fazer algo legal para demonstrar que deu certo o voto;
}
})
});
what I did was...first I make a FB.api call to get the users name, in the callback I make a FB.api call to register the action VERY IMPORTANT TO PASS THE ACCESS_TOKEN TOO...and must be POST.... and that is all there is to it! very cool right? And all that code is inside a function my app calls whenever the user votes and sends a boolean value that I use as the answer to know if the user voted 'yes' or 'no'.
That is all very good and is working fine! Just fine....
My problem now is that now when the action is published in my timeline and newsfeed and stuff it sends the user to this link below...it has absolutely nothing visual in it...it is the poll's data...a bunch of metatags...
i'd like to know if it is possible to send the user to another link when he/she clicks the link of my feed...
http://www.limonadaweb.com.br/genericco/poll_data.php?fb_action_ids=10150744684398313&fb_action_types=genericco%3Avotar_poll&fb_source=other_multiline

Error using news.reads Open Graph action

I'm trying out the new Open Graph actions to build functionality like the Washington Post Social Reader. I created OG pages of type "article" and posted "news.reads" action to them. I verified that the pages are valid OG objects using the OG debugger. And the user granted the publish_actions permissions.
I publish an action with an HTTP POST to:
https://graph.facebook.com/me/news.reads?article=((article link))&access_token=...
I get this error back from Facebook:
type = u'OAuthException', message = u'An unknown error has occurred.'
So I try the same action again, and this time I get this other error:
type = 'OAuthException'
message = '(#3501) User is already associated to a article object on a unique
action type Read. Original Action ID: ((action id))'
Where ((action id)) is a valid action ID, which I can verify by viewing:
http://graph.facebook.com/((action id))
Which gives me details about the action. I tried the above several times with different pages and different users, and it's the same flow: unknown error, duplicate action error. It looks like the action is being created, however:
I don't see it on the user timeline.
And I don't see it in the Activity Log.
What am I missing?
Note If I do the above using my own app-specific nouns and verbs, everything works as expected. But I'm interested in using the built-in nouns and verbs for better aggregation on users timelines.
If you action has not been approved by Facebook, it won't show up to end-users. Only those listed in the 'Roles' section of the Application Settings will be able to publish and see the actions in the Activity log (e.g. administrators, developers and testers).
Try testing the action with a Test User. Create a new test user from the 'Roles' page and login with them. See if the action is published and appears correctly on the Activity log.
Here's what I'm using to post video watches, you can try to do the same:
function postWatch()
{
FB.api('/me/video.watches' +
'?video=<?php echo $url; ?>','post',
function(response) {
if (!response || response.error) {
alert(response.error);
} else {
//alert('Post was successful! Action ID: ' + response.id);
}
});
}
The built in Read action is defined as "unique" while your action type is not (see 'advanced' section in the action edit screen). You you can't submit Read with the same object url twice.