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
Related
I'm trying to delete one user from _User table of parse.com but I get an error.
I'm sure that the syntax of the request is fine, I'm getting this error:
code: 206
error: "Parse::UserCannotBeAlteredWithoutSessionError"
I think I shouldn't to do log-in to delete users, because I'm doing it on API REST.
$scope.delete = function (id) {
$http({
method: "DELETE",
url: url_users + id,
headers: {'X-Parse-Application-Id': appId,
'X-Parse-REST-API-Key': restId}
}).success(function (data) {
debugger;
swal("Deleted!", "All user data has been deleted", "success");
}).error(function (data) {
debugger;
swal("Error!", "An unexpected error ocurred, try again!", "error");
});
}
You're trying to remove a user from a different user session to remove. This does not work from the REST API, even if you use the X-Parse-REST-API-Key in the headers. The solution is to use Clode Code Function to delete or update a user from another session.
For more information see the documentation Parse Cloud Code Guide
The following response is the Code Clode Function to delete a user:
Parse User Destroy - Javascript in Cloud Code
I haven't tried doing this, but I have these ideas:
Make sure your ACL allows this to the public
Is it not acceptable to call a cloud code function? This would feel more intuitive to me than using the API in this case. Can you explain why you must use the REST API?
If that doesn't work, look at this answer: https://www.parse.com/questions/delete-a-user-rest-api
Basically you might have to pass the Master Key header, which is less than ideal to expose to the public. Is it not accep
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
I am developing a simple Facebook app which will basically just allow users to POST statuses, photos, etc. - this is just an exploratory project at the moment.
I have been trying to POST statuses with varying privacy levels and have been able to POST with custom privacy successfully, however, when I try to tag a friend in the POST headers I get an oAuth exception error response.
My scope appears to include everything necessary to do what I want, but I may be missing something here.
"...&scope=email,user_groups,user_photos,read_friendlists,manage_friendlists,publish_stream,read_stream"
Here's my JS code:
FB.api(
"/me/feed",
"POST",
{
"message": $('textarea').val(),
"tags": $('input').val(),
"privacy" : {'value': 'CUSTOM','allow': $friend_list.val() }
},
function (response) {
if (response && !response.error) {
console.log('response is: ');
console.log(response);
}
else{
console.log('oops something went wrong here!');
console.log(response);
}
}
);
As the SDK docs are not really that informative, I am not really sure what the purpose of place, which I apparently have to include:
Comma-separated list of user IDs of people tagged in this post. You
cannot specify this field without also specifying a place.
I have tried setting "place" as a variety of values but I'm not sure what I am doing wrong. I have deliberately omitted it from the example code above by the way.
Thanks in advance
-- EDIT --
As requested, here is an example list of the headers being posted:
message:this is an example post
method:post
privacy:{"value":"CUSTOM","allow":"123456789012345"}
The above works correctly (given the correct user ID's that is), i.e. a status is created and it is only viewable by a single user/friend, but once I include "tags" it throws an oAuth error with little to no info or explanation. The reason I am trying to "tag" friends by the way is that I want people to be notified of a POST rather than just having access to it.
message:this is an example post
method:post
privacy:{"value":"CUSTOM","allow":"123456789012345"}
tags:123456789012345
I have also tried to set the "place" header, but again I have little understanding of its purpose so I may be supplying an incorrect value or something like that.
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
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.