This is my code:
$curl1 = curl_init();
$url = "https://bitbucket.org/api/2.0/repositories/webesian/jobmarkt/pullrequests/";
curl_setopt($curl1, CURLOPT_HTTPAUTH, CURLAUTH_BASIC );
curl_setopt($curl1, CURLOPT_USERPWD, "***:***");
curl_setopt($curl1, CURLOPT_HEADER, true);
curl_setopt($curl1, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($curl1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl1, CURLOPT_URL, $url);
curl_setopt($curl1, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($curl1);
My problem is that the output variable is not json only. There's some other crap inside. How can i extract only the json from the response?
You have CURLOPT_HEADER
set to true, so it will output the header info as part of the response. Removing that or setting it to false should solve the problem
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.