fsi
fsi

Reputation: 1367

Facebook javascript JSON Error message

Im using Cordova facebook plugin. And I copied from somewhere this code to post wall on my facebook and this error is saying Post ID: "JSON Error". What I'm doing wrong?

var opts = {
    message : 'test',
        name : 'Post Title',
        link : 'www.postlink.com',
        description : 'post description'
    };

facebookConnectPlugin.api('/me/feed', 'post', opts, function(response) {
    if (!response || response.error) {
        alert('Error occured ' + JSON.stringify(response.error));
    } else {
        alert('Post ID: ' + response);
    }
});

Upvotes: 1

Views: 574

Answers (2)

Daniel Kopitchinski
Daniel Kopitchinski

Reputation: 525

It seems you're using this Apache Cordova Facebook plugin, but calling the functions based on the Facebook SDK documentation.

These are 2 separate SDKs. They have different functions, and they get different parameters. This is how the api function is defined in the cordova plugin:

facebookConnectPlugin.api(String requestPath, Array permissions, Function success, Function failure)

It expects different parameters then the one's what you're sending.

https://github.com/phonegap-build/FacebookConnect/

Upvotes: 1

Nicolò Taddei
Nicolò Taddei

Reputation: 96

it might be the fact that the Cordova FB api is different from Facebook's sdk.

https://github.com/Wizcorp/phonegap-facebook-plugin#the-graph-api

It requires as the first parameter the url to call, the second parameter is the permissions required, third a success callback and fourth an error callback.

Its not clear from the documentation how you should actually execute your request and how to add parameters to the request.

Upvotes: 1

Related Questions