5

I'm trying to do the following using FB's official PHP SDK:

$facebook->api(
'/me/feed',
'POST',
array(
    'link' => 'test',
    'message' => 'test'
)

)

Unfortunately, the server (not facebook!) returns a 500 error.

The request goes through, the status gets posted, but my server returns an error.

My question is, how do I find out what's the cause of it?

pnuts
  • 58,317
  • 11
  • 87
  • 139
Lior
  • 5,454
  • 8
  • 30
  • 38

2 Answers2

6

500 is generally "internal server error".

If you get 500 back from your facebook api call, then it might be something wrong on their end.

Then again, your HTTP requests might be a little off, and the fb server goes "um, what?" and sends you a 500 because it can't explain the problem.

I remember a number of years ago the fb api returned mostly "unknown error" codes when something went wrong - haven't touched that api since. Hopefully you're not running into the same problem.

To really solve the problem, you will need to either:

A) capture your HTTP request and response, including the headers, compare it to a successful api call, and make changes if needed. B) capture any exceptions thrown by the facebook SDK.

Option A will always work, but option B is perhaps quicker.

Check out: php exceptions

EDIT: to see what is causing a 500 error on YOUR server, look in your apache error logs.

you can also use

error_reporting(E_ALL);

to rule out any php errors.

okayGraphics
  • 375
  • 2
  • 10
  • I probably didn't properly explain myself: The server returns a 500 code, not Facebook. I would assume that if it was facebook, then the request would just fail and my server wouldn't return a 500 error. The status gets posted, it doesn't seem like there is a problem on FB's end. – Lior Jan 16 '12 at 20:15
  • in that case your apache error logs should tell you what the problem is. – okayGraphics Jan 16 '12 at 20:57
0

In my case i moved the application from one server to another and the missing CURL was the bug :)

In administration mode ssh i could see following line>

PHP Fatal error: Uncaught exception 'Exception' with message 'Facebook needs the CURL PHP extension.' in /srv/www/smixe.com/base_facebook.php:19

Stefan Michev
  • 4,795
  • 3
  • 35
  • 30