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.
Related
I'm using the following Javascript for my users to send requests to "invitable friends" from my Facebook app:
FB.ui({
method: 'apprequests',
message: 'Come play with me etc.',
to: str_ids
},
requestCallback
);
function requestCallback(response){
if(response){
console.log(response);
}
else{
//show error to user
}
}
Where str_ids is a string containing the IDs returned by the invitable friends API. This all works fine.
When I invite a single user, let's say his Facebook ID is 1593894704165626, I get the following response:
request
"1399842883640198"
to
["1593894704165626"]
So here I have a unique request ID and the invited person's Facebook ID. I can now store this data in my database along with the inviter's ID, so I have all the necessary info.
However, now I want to reward the inviter after the invitee accepts the invitation and I'm running into a problem.
If user A and user B both invited user C, then when user C joins the game, how do I know whether to reward A or B?
I see from this question that it's possible to pass another parameter along with the invitation, which should help identify the inviter:
Facebook tracking who Invited whom
The first answer here suggests that you can pass such a custom parameter, but doesn't say how. Facebook's convoluted documentation is driving me insane.
Another thing - even if I send that additional parameter, I think there's a problem - for new users the app redirects to the Facebook page that checks whether they want to allow access to the app, and by the time they're redirected back to the app, the additional parameter will be lost.
Is there any solution to this?
I want to follow up this question. I use FB.ui to send link and got exactly the same error for some users. Is there anyway to check it and decide whether to display the ui to the user ?
API Error Code: 100
API Error Description: Invalid parameter
Error Message: Viewer cannot message specified recipients.
<a href='#' onClick="
FB.ui({
method: 'send',
link: 'http://www.xxxxxxxxxxx.com',
to: ###########,
});
">Send a message</a>
Even when I use the url send method, some user does not work. For example:
Error User : https://www.facebook.com/dialog/send?app_id=123050457758183&name=People%20Argue%20Just%20to%20Win&link=http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html&redirect_uri=https://www.bancsabadell.com/cs/Satellite/SabAtl/&to=100000104626944
Normal User: https://www.facebook.com/dialog/send?app_id=123050457758183&name=People%20Argue%20Just%20to%20Win&link=http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html&redirect_uri=https://www.bancsabadell.com/cs/Satellite/SabAtl/&to=1311251197
(this is the share link example taken from https://developers.facebook.com/docs/reference/dialogs/send/)
bug reported to facebook: https://developers.facebook.com/bugs/538638372825668
Edit: in fact, everyone should be reachable through messages now. It's only there are new "filtering preferences". I guess this can_message field is now useless because it should always return true. I think it is going to be deprecated in a while.
In the user FQL table, you have a field that must verify what you need:
can_message (boolean): whether the user can send a message to another user
Source: https://developers.facebook.com/docs/reference/fql/user
select can_message from user where uid=USER_ID
USER_ID being the person that your app user want to send a message to.
You can use the FB api;
I use something like:
FB.api('/me/permissions', function (response)
{
//check contents of response for required permissions here
fb_publish_perm = response.data[0]['publish_stream'] ? response.data[0]['publish_stream'] : false;
if (fb_publish_perm)
{
// it permissions exist
}
else
{
// permissions dont exist launch the ui to request.
}
});
Please treat the above as psedo code, as it came straight off the top of my head!
I have implemented FB Multi Friend Selector as explained on this page https://developers.facebook.com/docs/reference/dialogs/requests/
function sendRequestViaMultiFriendSelector() {
FB.ui({method: 'apprequests',
message: 'My Great Request'
}, requestCallback);
}
However I want to send the custom Url to the User, since my Facebook App has some parameters at the end like below
http://apps.facebook.com/MY_APP_NAME/MY_PARAMETERS
However with the above method, the user is getting the following link with the MY_PARAMETERS Omitted
I cann't see any "url" parameter in the "apprequests" method. However, this is something that Sweepstakes does successfully. They are able to pass all their parameters in the Message and I want to copy the same functionality.
Thanks in Advance.
The request will point the accepting user to your canvas URL – there is nothing you can change about that.
However, if you need to pass custom data along “with” the request – there’s the data parameter of the dialog for that. You will get the info you put in there back, after reading the details of the request object from the API.
I am creating a web application that displays a list of images taken from Flickr and I would like a user to login through Facebook and allow them to comment on those images. I was able to get the login/authentication working but I am now having trouble to enable a user to add a comment (as oppose to a Facebook 'post') on a Flickr image and have this activity show up on the user's Facebook profile/feed (i.e "John Smith commented on a link").
Here is what I have so far:
var fbCommentApi = '/me/myappname_ns:comment?access_token=' + fbUserToken + '&method=post' + '&picture=[WEBSITE_URL]' + selectedItemId;
FB.api(
fbCommentApi,
'post',
{ message: txtObj.value },
function (response) {
if (!response || response.error) {
alert("Sorry, there was a problem. Please try again later. [API]");
}
else {
alert("Thank you. Your comment will appear shortly");
hideCommentBox(txtObj);
}
}
);
The above code doesn't create a comment but instead it creates a post on the user's timeline with the URL attached. So when I try to retrieve comments for the WEBSITE_URL item through Facebook Graph...
'https://graph.facebook.com/comments/?id=[WEBSITE_URL]' + itemID
...I end up with empty data being returned.
I have an Action Type called 'Comment' in my Facebook app and that's the action I am using when trying to add the comment.
Thanks in advance and I look forward to your answers.
UPDATE 1: It seems now that if I use Facebook Graph this way.. graph.facebook.com/me/appname_ns:discuss?access_token=[TOKEN]&website=[URL]&method=post
..it would just add an entry to the user's Activity box in their timeline, I didn't even pass a comment or message parameter to the URL as a query string parameter. That could be part of the problem.
UPDATE 2: According to another StackOverflow question, there seems to be no way to get a view of all actions done by all users, it has to be done per user (an API call per user). Therefore another way of handling this particular issue is to save the comments (or whatever action performed) to our own database.
Well, an Open Graph action is not a comment, even if you name it comment …
If you want a real Facebook comment, then either get a reference to an object that actually can be commented upon; or substitute comment with post/link post.
I can't seem to get a post to work for our news items as FB News items. I was able to create a whole custom type and I discovered the News specific option after I had implemented a standard object:action setup successfully so conceptually this should work since we had all the pieces working before.
Originally we (GlobalPost) created out own app and Auth for our own name space gp_storyshare for our article object with a action read.
Then I ran over this
https://developers.facebook.com/docs/opengraph/news/
and sighed, since it wasn't linked to any of the other documentation and started over. Here is where I'm at.
Since then I have added in all the news specific OG tags and altered our og type to
without any name space
see good example page with tags here
http://www.globalpost.com/dispatch/news/regions/asia-pacific/111206/burma-myanmar-aung-san-suu-kyi
I have not done anything to our App, not sure if I need to make any auth changes or anything as the developer page says nothing and the object isn't mine to control. ** I have a feeling this is the issue but no real proof.**
on window.load I call newsRead() seen below, like I did before. This doesn't work.
function newsRead()
{
FB.api('/me/news:reads' +
'?article=http://www.globalpost.com/$node->path','post',
function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post was successful! Action ID: ' + response.id);
}
});
I just have no idea what to try next. Any help is appreciated.
For any of the open graph actions (including built-in) you'll need the publish_actions permission, but it's still in beta at the moment and will only work for registered developers and testers of the app - I'm not aware of any other specific restrictions, but I think you're probably going to be posting 'Article' objects ( https://developers.facebook.com/docs/beta/opengraph/objects/builtin/ )