0
function marketcurencylist($auth,$id)
{
    $context = stream_context_create(
        array("ssl"=>array(
            'verify_peer'=>false,
            'verify_peer_name'=>false,
        ),

        'http' => array(
        'method' => 'GET',
        'header' => "Content-Type: application/json\r\n"."Authorization:".$auth."\r\n",
        )
    ));
    $response = file_get_contents(api_url().'market/allactivemarketslist', false, $context);
    return $response;
}

failed to open stream: HTTP request failed! HTTP/1.0 500 Internal Server Error

DsRaj
  • 2,288
  • 1
  • 16
  • 26
  • 1
    please format your code block and provide more details to the error like a full stack trace and how to reproduce it and etc... – shahaf Jun 18 '18 at 13:10
  • "500 Internal Server Error" (or a blank page) means your script is throwing an error but PHP is configured to hide it from you. You need to fix it ASAP because coding without the aid of error messages is hard. As quick start, you can set the `error_reporting` and `display_errors` directives in your computer's system-wide `php.ini` file ([details here](http://stackoverflow.com/a/5680885/13508)). Errors thumb rule: show in development, log in production. – Álvaro González Jun 18 '18 at 13:15
  • @Álvaro your right of course as far as local development is considered, but I suspect `api_url()` might be an external URL here - and in that case, all error reporting on the local dev machine won’t help much in that regard. – CBroe Jun 18 '18 at 13:30
  • @CBroe Hmmm... I had taken for granted the 500 status was being sent by his script. What you say probably makes more sense. – Álvaro González Jun 18 '18 at 13:32
  • Possible duplicate of [Why I'm getting 500 error when using file\_get\_contents(), but works in a browser?](https://stackoverflow.com/questions/10524748/why-im-getting-500-error-when-using-file-get-contents-but-works-in-a-browser) – Ulrich Dohou Jun 19 '18 at 07:37
  • By the way best option will be to use `curl`. Check this https://stackoverflow.com/a/47296900/6261137 – Ulrich Dohou Jun 19 '18 at 07:38

1 Answers1

0

allow_url_fopen must be disabled on your server. Either you can try enable it via php.ini or consider using cURL functions.

SynapseIndia
  • 450
  • 2
  • 10