Timeout when trying to access an HTTPS rest service via PHP

1

I'm trying to access a rest service that is on an HTTPS server via PHP and is returning timeout. If I take the URL and put it in the browser it opens. I'm using Httpful ( link ), I've already used other libraries and the same error occurs. Now when I access a rest service that is on an HTTP server it works.

Below the code I'm using

$url = "https://api.github.com/users/nategood";
echo "<br>{$url}<br>";
$response = \Httpful\Request::get($url)
        ->strictSSL(true)
        ->send();
echo "<br>";
var_dump($response);

The result of the above execution is:

link

Fatal error: Maximum execution time of 30 seconds exceeded in phar: // C: /xampp/htdocs/project_01/httpful.phar/Httpful/Request.php on line 202

Can anyone help me?

    
asked by anonymous 10.01.2017 / 15:23

2 answers

0

By analyzing the API service, it means that there is a defined%% (I believe the problem comes from), this approach does not involve User-Agent and I even believe it is not necessary:

$opts = array(
  'http'=>array(
    'header'=> "User-Agent: Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.102011-10-16 20:23:10\r\n"
  )
);

$context = stream_context_create($opts);
$response = file_get_contents('https://api.github.com/users/nategood', false, $context);

Where the contents of \Httpful\Request will be:

  

{"login": "nategood", "id": 154115, "avatar_url": " link "," gravatar_id ":" "," url ":" link "," html_url ":" link "," followers_url ":" link "," following_url ":" link {/ other_user} "," gists_url ":" link {/ gist_id} "," starred_url ":" link {/ owner} {/ repo}", "subscriptions_url": " link , "organizations_url": " link ", "repos_url": " link "," events_url ":" link {/ privacy} "," received_events_url ":" link "," type ":" User "," site_admin ": false," name ":" Nate Good "," company ":" ShowClix, Inc. "," blog ":" link

10.01.2017 / 15:33
-1

To test, try to allow the source:

header('Access-Control-Allow-Origin: *'); // libera acesso de todos os sites

If successful, replace the asterisk with the URL of the domain you are using.

header('Access-Control-Allow-Origin: https://www.seu_site.com', false);

In addition, check that the SSL certificate is valid and that the SSL version is supported.

    
10.01.2017 / 15:31