I've created a custom object, called 'Opinion' to build custom stories around it.
I'm trying to add some app-owned objects from my website using the javascript sdk.
The sample code facebook gives me is:
FB.api(
'me/objects/[namespace]:opinion',
'post',
{
app_id: xxxxxxxx,
type: "[namespace]:opinion",
url: "",
title: "Sample Opinion",
image: ".png",
description: ""
},
function(response) {
// handle the response
}
);
The reponse is an error (OAuth Exception):
2500: Cannot specify type in both the path and query parameter.
If i remove the type
parameter, i get another error:
(#100) The parameter object is required
Same if I remove [namespace]:opinion
from the path.
I don't understand why, and there's no reference about this after googling it.
Why this? Any resource i can refer to solve that?
I've created a custom object, called 'Opinion' to build custom stories around it.
I'm trying to add some app-owned objects from my website using the javascript sdk.
The sample code facebook gives me is:
FB.api(
'me/objects/[namespace]:opinion',
'post',
{
app_id: xxxxxxxx,
type: "[namespace]:opinion",
url: "http://samples.ogp.me/331257847005141",
title: "Sample Opinion",
image: "https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png",
description: ""
},
function(response) {
// handle the response
}
);
The reponse is an error (OAuth Exception):
2500: Cannot specify type in both the path and query parameter.
If i remove the type
parameter, i get another error:
(#100) The parameter object is required
Same if I remove [namespace]:opinion
from the path.
I don't understand why, and there's no reference about this after googling it.
Why this? Any resource i can refer to solve that?
Share Improve this question asked Jun 17, 2013 at 17:46 apelliciariapelliciari 8,5019 gold badges58 silver badges93 bronze badges2 Answers
Reset to default 19The object is a JSON-encoded version of an object, the sample code generated for you was incorrect. Also remove type from the parameter list.
So something like,
FB.api(
'me/objects/[namespace]:opinion',
'post',
{
object: {"app_id":xxx,"url":"http:\/\/samples.ogp.me\/331257847005141","title":"\"Sample Opinion\"","image":"https:\/\/s-static.ak.fbcdn.net\/images\/devsite\/attachment_blank.png","description":"\"\""}
},
function(response) {
// handle the response
}
);
An example of how it looks can be seen at http://philippeharewood.com/facebook/objectify.html and it was based off the curl example given at https://developers.facebook.com/docs/opengraph/using-object-api/
For anyone struggling with a similar problem on iOS, the sample code again appears to be wrong, however the following seems to work:
NSMutableDictionary<FBOpenGraphObject> *object =
[FBGraphObject openGraphObjectForPostWithType:@"<appnamespace>:<objecttype>"
title:@"..."
image:[result objectForKey:@"uri"]
url:nil
description:@"..."];
[FBRequestConnection startForPostOpenGraphObject:object completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
// handle the result
if ( error ) {
DLog(@"error %@ creating object", error);
} else {
...
}
}];