FB api - Error when posting picture on page wall - javascript

I am trying to create a post on a page wall with the FB api. Like this:
FB.api(currentpage.id+'/feed','post',{
access_token:page_access_token,
scheduled_publish_time:eventstart.valueOf()/1000,
published:false,
link:eventlink,
picture:'http://addsocial.net'+eventimg,
message: eventtitle,
}, function(rsp) {
});
Everything works fine, if i'm not adding any picture parameter to the post. I get a post-id in return and all is good. But as soon as I add my picture (e.g: http://addsocial.net/mba/media/events/383419425113154/3-buu.png), it gives me the following error:
error: Object
code: 1
message: "(#1) An unknown error occurred"
type: "OAuthException"
proto: Object
proto: Object
I know its not the URL, because if I remove http://addsocial.net it gives the error: picture URL is not properly formatted. But with this error message, I cant derive anything from it.
Anybody experienced this before, please let me know. Thanks

Related

Facebook Graph API private_replies with page access token throws an error

I'm trying to send private replies as a page with the Graph API:
FB.api( '/' + id + '/private_replies', 'post',
{ message: message, access_token: token }, function(res) {}
);
The comment id is fine. The access token has been generated correctly. I have read_page_mailboxes permission. Despite all that, the API throws back this:
{
"error": {
"message": "(#10903) This user cant reply to this activity",
"type": "OAuthException",
"code": 10903,
"fbtrace_id": "BW3yOdmwnhi"
}
}
Am I missing something?
The problem appears to be the fact that I tried to reply to my own comments. That is not allowed. Only comments from others are allowed to reply to. Also, once replied to, the comment cannot be replied to ever again. That will throw a (different) error as well.
I also encountered the same problem. The reason might be your page is not published yet.

Error: Permission denied to access property 'nodeType' on AJAX request in Firefox

I include the Google Sign-in button on my page, and use gapi to interact with it. When the user successfully authenticates using the Google API , I make an AJAX call using JQuery to my server:
var token = gapi.auth.getToken();
var data = {
"token": token,
"userId": googleResponse.id
};
console.log("sending data");
console.log(data);
$.post(url, data, function(response) {
window.location.reload();
}, "json").error(function(responseObj, statusCode) {
var response = responseObj.responseJSON;
console.log("error");
console.log(response);
console.log(statusCode);
});
I see this issue in the console:
"sending data"
Object { token: Object, userId: "xxxxxxxxxxxxxxx" }
Error: Permission denied to access property 'nodeType'
The page does not reload and I do not see additional info in the console.
I do not use JQuery to access any element properties or manipulate the DOM in any way.
This issue happens with Firefox 36.0.1 and JQuery 2.1.1, but not with Chrome or Safari (same page, same code), on my Mac.
EDIT There were posts suggesting FireBug is to blame, so I disabled it and restarted Firefox, but it didn't help.
I figured this out by taking a closer look at the token object I was sending: the token object contains a field called g-oauth-window, which contains a reference to the DOM object which created it. When you pass this token inside of a $.post request, JQuery will resolve this field, and it makes Firefox bug out. Blanking out this field (setting it to null) makes everything work!

Listing all the Facebook photos a user is tagged in using response from FB.api

Right now I'm using the Facebook APIs through JavaScript. So far I can log myself in, and now I'm trying to get information about a user who logs into my website. Here is what I have so far:
FB.api('/me/photos', function(response) { console.log(response); } );
However, the response only says: "Object {data: Array[0]}", and the Array is empty.
I've also tried using this code:
FB.api('/me?fields=photos', function(response) { console.log(response); } );
The response I get from the console is: "Object {id: "10152784292783838"}".
How can I get all the photo information? The only ideas I thought of are that I'm not using an access token, but when I tried that it still didn't work. I'm also including 'user_photos' in my scope when I log the user in, but it doesn't change the response. What am I doing wrong?
As long as you're using the app's admin/tester/developer users, you should be able to get the data. If not, the array will be empty, because facebook requires an app review for apps which request more than the basic permissions.
See
https://developers.facebook.com/docs/apps/review/login#do-you-need-review

Facebook payments API - Error with no code

I am implementing the Facebook payments API and receiving an odd error dialog with no populated data, it basically looks as follows:
An error occurred, Please try again later.
API Error Code:
API Error Description:
The javascript returns a null object in the callback.
JS implementation:
FB.ui({
method: 'pay',
action: 'purchaseitem',
product: 'http://localhost:8000/PRODUCT_URL',
},
function(data) {
console.log(data);
});
Any help would be much appreciated.
Found the error: Seems like the product value was incorrect - whether thats because its hosted locally i'm not sure but it worked when I used a valid product from Facebook's 'Friend Smash' example.
Hope this helps someone

What are the proper parameters for posting flash content using the Facebook Javascript SDK?

I am able to successfully post Flash content using FB.ui({method: 'stream_publish',....}).
However, since my app must also be able to post to Fan Pages, I cannot use FB.ui, and must use the Graph API via FB.api instead. No biggie, I'd rather have a custom form for posting anyway.
But it seems posting to a feed using FB.api('/FEED_ID/feed', ...) takes different parameters than the FB.ui method.
Documentation for the FB.api call and the Graph API is not particularly helpful. The Graph API docs mention a source parameter, which is supposed to be the url to the flash object. However, when I set source to be the flash object url, I get the following:
(#100) flash objects must have the 'swfsrc' and 'imgsrc' attributes.
OK, fine, but where do they go? The attachment parameter, which worked fine for FB.Connect and FB.ui, seems to be completely ignored.
Here's my code:
body = {
name: "Name",
link: "http://mysite.com/link_to_my_content",
caption: "This is the caption",
message: "Test Message",
source: 'http://mysite.com/static/flash.swf',
image: 'http://mysite.com/static/images/facebook_thumb.png',
actions: action_links,
description: "The fascinating, compelling description"
}
FB.api('/me/feed', 'post', body, function(response){
if (!response || response.error){
console.log("FB.api error occurred");
if (response.error){
console.log("Error message: " + response.error.message);
}
}
else {
console.log("Post successful: " + response);
}
});
When posting to a Fan Page I also include the access_token parameter (and changing the url obviously) which seems to work fine. I just can't figure out how to get the flash content to publish. Where do the swfsrc and imgsrc attributes go? It's probably something that will seem obvious but I've tried everything I can think of. Google isn't helpful as it seems most people are just using stream_publish, and a bunch of old FB.Connect stuff.
Just found out that you have to supply picture when posting a source swf, or else you receive the imgsrc/swfsrc error message. See http://bugs.developers.facebook.net/show_bug.cgi?id=10672#c17
Go Facebook.

Categories