开发者

Using PHP5 Curl to call Facebook Graph API. Different servers getting different responses

I have a PHP app that uses Curl to call the Facebook Graph API and post items to a user's wall. It works great on my dev box and our production servers, but it doesn't work on one QA server. We're getting a nebulous error code 100: "Message Failed" back. As far as I can tell, I'm sending the same information from all servers.

Here's my request on the dev box:

Array
(
    [0] => Accept: text/html,application/xhtml+xml,application/xml;q=0.9;q=0.8
    [1] => Accept-Language: en-us,en;q=0.5
    [2] => Accept-Charset: utf-8;q=0.7,*;q=0.7
)
POST: https://graph.facebook.com/me/feed
{
    "message":"my message",
    "picture":"http:\/\/server.com\/image.jpeg",
    "link":"http:\/\/server.com\/page",
    "name":"foo",
    "caption":"bar",
    "access_token":"{ACCESS_TOKEN}"
}

Here's the response (it works):

{
   "id": "6705254_873254004878"
}

Here's my request on the QA box (same ACCESS_TOKEN):

Array
(
    [0] => Accept: text/html,application/xhtml+xml,application/xml;q=0.9;q=0.8
    [1] => Accept-Language: en-us,en;q=0.5
    [2] => Accept-Charset: utf-8;q=0.7,*;q=0.7
)
POST: https://graph.facebook.com/me/feed
{
    "message":"my message",
    "picture":"http:\/开发者_如何学编程\/server.com\/image.jpeg",
    "link":"http:\/\/server.com\/page",
    "name":"foo",
    "caption":"bar",
    "access_token":"{ACCESS_TOKEN}"
}

Here's the response on QA (fail)

{
   "error": {
      "type": "OAuthException",
      "message": "(#100) Message Failed"
   }
}

I have removed the actual URLs we're sending for picture and link, but you get the idea :)

Does anyone know what I could be doing wrong? It looks the same to me....


Hey, I think its a problem with the Site URL given in your app settings. Facebook only allows requests from the domain listed in your application settings.


As far as I understood facebook policy, only one client can authorise with particular acess token - so you should get a new one before posting. It was described here: Facebook: "This authorization code has been used.","type":"OAuthException","code":100

So you should add

$access_token = $session->getToken();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜