I have started dabbling with Facebook Graph api fairly recently. I have defined a custom action ‘Start’ with the namespace ‘Test’, here is the code I use to for posting to Facebook.
FB.api('/me/Test:start',{ article : currentURL, message: $j('.subject-content h2 a').html()}, 'post', function(response) {
if (!response || response.error) {
console.log('Error '+response.error.message);
}
else {
console.log('Message was posted! (post id: ' + response.id + ")");
}
});
for some reason this post fails the first time, but on subsequent tries, the post succeeds.
Here are the requests I captured from firebug.
1)
access_token xxxxx
article https://testserver:8080/xxx
callback FB._callbacks.__gcb2
message testpage
method post
pretty 0
sdk joey
2)
access_token yyyy
article https://testserver:8080/xxx
callback FB._callbacks.__gcb6
message testpage
method post
pretty 0
sdk joey
As you can see the calls are exactly the same. The first time I get this response
/**/ FB._callbacks.__gcb4({"error":{"message":"An unknown error has occurred.","type":"OAuthException","code":1}});
I tried the same requests on the graph explorer as well, it works every single time.
Am I doing something wrong? Any help would be great.
Thanks in advance.
Fixed the issue. I was executing two post request simultaneously and this one would consistently keep failing, so I thought there was some problem with this request.
I don’t know what the problem was but when I separated these two requests. Everything worked as expected.