0

I checked and it looks like cURL is enabled inside the php.ini file (I'm using XAMPP) and yet it's still not displaying anything. Same thing goes for file_get_contents. I simply get a blank web page as a result...

<body>
<?php
$auth = base64_encode("04d2ac7f76a0fbc0eee9dc5ef96b9259:dc70ffc7ad911236bc2e0822855e2d42");
$context = stream_context_create(['http' => ['header' => "Authorization: Basic $auth"]]);
$homepage = file_get_contents("https://api.intrinio.com/companies?identifier=AA", false, $context );


$login = '04d2ac7f76a0fbc0eee9dc5ef96b9259';
$password = 'dc70ffc7ad911236bc2e0822855e2d42';
$url = 'https://api.intrinio.com/companies?identifier=AA';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$login:$password");
$result = curl_exec($ch);
curl_close($ch);  
echo($result);
?>
</body>

Anyone has an idea why? Thanks!

user3080698
  • 61
  • 1
  • 1
  • 9
  • And what does your PHP error log tell you? – Martin Dec 17 '17 at 23:04
  • 3
    Take a look at [how to enable error reporting here](https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display?rq=1) and see if you get some error output that helps you. Also, you probably can remove the `` part there. – deR_Ed Dec 17 '17 at 23:04
  • Removed the unnecessary html tags and checked if error reporting is on in the php.ini- it is. Also, added this to the code: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); but still nothing- empty page. – user3080698 Dec 17 '17 at 23:12
  • I put your code in a test.php file and ran in localhost on MAMP and it works fine. – Maarten van Middelaar Dec 17 '17 at 23:19
  • 2
    I hope your auth token/key is disposable. – Scuzzy Dec 17 '17 at 23:20
  • I see. So what am I supposed to do now then? Is it a problem with XAMPP/my network or something? Any idea? Thanks. – user3080698 Dec 17 '17 at 23:20
  • @deR_Ed answer is what you should be doing, you need to confirm if your local environment is halting on errors. – Scuzzy Dec 17 '17 at 23:23
  • I'm not getting anything back when I do what he mentions. – user3080698 Dec 17 '17 at 23:27

1 Answers1

0

Solution:

$auth = base64_encode("04d2ac7f76a0fbc0eee9dc5ef96b9259:dc70ffc7ad911236bc2e0822855e2d42"); 
$context = stream_context_create(['http' => ['header' => "Authorization: Basic $auth"]]); 
$homepage = file_get_contents("https://api.intrinio.com/companies?identifier=AA", false, $context ); 
$jsonary = json_decode($homepage,TRUE); 
print_r($jsonary); 

That said, curl still isn't working so if someone has an idea on how to fix it then I'd still appreciate if you could let me know.

user3080698
  • 61
  • 1
  • 1
  • 9