Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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....

like image 777
lyonbro Avatar asked Nov 04 '22 23:11

lyonbro


1 Answers

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.

like image 192
Kartik kar2905 Avatar answered Nov 10 '22 15:11

Kartik kar2905