Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trace the cause of a 500 internal server error?

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?

like image 344
Lior Avatar asked Jan 16 '12 19:01

Lior


1 Answers

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.

like image 77
okayGraphics Avatar answered Oct 13 '22 09:10

okayGraphics