2016-04-13 17 views
0

私はBitriseで作業しており、PHPでAPIを使用しようとしました。 は、だから私はPHPで、このシェルコマンドを変換しようとした:JSONデータを含むPHP Curl

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"}}' 

誰かが私を助けることができますか?私の結果は毎回偽です。 私のコードを使用:

$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は私に私の「秘密」のURLやデータの情報を与える、ここでは、URLと、与えられたデータの一例に過ぎパターンです。

ありがとうございます。

答えて

0

カールを使用してコードイムは、このようになり、そして唯一の違いは、それは私にデータを返すヘッダ

$contact = json_decode(file_get_contents("https://api.xxxxx.com/contacts/v1/search/query")); 
if ($contact->contacts){ 
     $vid = $contact->contacts['0']->vid; 


     //Need to populate these varilables with values from the form. 
     $str_post = '{"properties": [{"property": "resume_link", "value": "'.$link.'"}]} '; 

     //replace the values in this URL with your portal ID and your form GUID 
     $endpoint = 'https://api.xxxx.com/contacts/v1/contact/vid/' . $vid . '/profile?hapikey=xxxx'; 

     $ch = @curl_init(); 
     @curl_setopt($ch, CURLOPT_POST, true); 
     @curl_setopt($ch, CURLOPT_POSTFIELDS, $str_post); 
     @curl_setopt($ch, CURLOPT_URL, $endpoint); 
     @curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/javascript')); 
     @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
     @curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS ,4000); 
     @curl_setopt($ch, CURLOPT_TIMEOUT_MS, 4000); 
     $response = @curl_exec($ch); //Log the response from HubSpot as needed. 
     @curl_close($ch); 

、あなたはエンドポイントがとき成功trueを返していることを確認しているあります??