3

I'm trying to do a simple GET request and return whatever the response is too the screen. When i load the page i get a blank page. I feel like im close, but im not sure where i am going wrong.

I'm assuming that i should get some kind of response if it worked succesfully.

    $url='https://api.bitbucket.org/1.0/user/';

    $curl = curl_init();

    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC ); 
    curl_setopt($curl, CURLOPT_USERPWD, "username:password");
    curl_setopt($curl, CURLOPT_HEADER, true); 
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_URL, $url);

    curl_exec($curl);
Adam Sweeney
  • 386
  • 3
  • 15

1 Answers1

3

To not return a blank page, you need to write

echo curl_exec($curl);

or delete this line:

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
Winston
  • 1,758
  • 2
  • 17
  • 29
  • 2
    Also you need add `curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);` `curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);` before curl_exec – Winston Feb 21 '13 at 20:11
  • This works great, i just needed to add the `curl_setopt($curl, CURLOPT_SSL_VERIFYPEER', false);` line – Adam Sweeney Feb 21 '13 at 20:16