PHP Curl with JSON data
878
I work on Bitrise and I tried to use there API in PHP. So I tried to convert this shell command in PHP :
curl https://www.bitrise.io/app/[APP-SLUG]/build/start.json --data '{"hook_info":{"type":"bitrise","api_token":"[API-TOKEN]"},"build_params":{"tag":"1.0.0"}}'
Someone can help me? My result is false everytime. My code used :
$data_json = '{"hook_info":{"type":"bitrise","api_token":"[API-TOKEN]"},"build_params":{"tag":"1.0.0"}}';
$url = 'https://www.bitrise.io/app/[APP-SLUG]/build/start.json';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
Bitrise give me my "secret" url and data informations, here it's just an example pattern of url and data given.
Thank you.
Answer
Solution:
The code im using with curl is as this, and the only difference is the header
it returns me data, are you sure the endpoint is returning true when success??