ZenDesk の API を使用して、Web サイトの支払いフォームからアカウント作成をセットアップしようとしています。彼らが与えるコード例は次のとおりです。
curl -v -u {email_address}:{password} https://{subdomain}.zendesk.com/api/v2/users.json \
  -H "Content-Type: application/json" -X POST -d '{"user": {"name": "Roger Wilco",     "email": "roge@example.org"}}'
PHP変数を含める必要があるため、これを使用しようとしています:
$data = array("name" => $entry["1"], "email" => $entry["3"], "role" => "end-user");                                                                    
$data_string = json_encode($data); 
$ch = curl_init('https://xxxx.zendesk.com/api/v2/users.json');
curl_setopt($ch, CURLOPT_USERPWD, "xxxx@example.com:xxxx");                                                                      
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
'Content-Type: application/json',                                                                                
'Content-Length: ' . strlen($data_string))                                                                       
);                                                                                                                   
$result = curl_exec($ch);
しかし、それは機能していません。最初のスニペットの機能を複製するという点で、私のコードは正しいですか?