我向 SAASU 发送请求以使用 REST API 创建新联系人,但我没有得到结果。请帮我。
方法一
$web_service = 'https://secure.saasu.com/webservices/rest/r1/Tasks?wsaccesskey=XXXXXXXXXXXXXXXXX&FileUid=XXX';
$xml = '<?xml version="1.0" encoding="utf-8"?><tasks><insertContact><contact uid="0"><salutation>Mr.</salutation><familyName>Smith</familyName><givenName>John</givenName><organisationName></organisationName></contact></insertContact></tasks>';
$cmd = 'curl -X '.' "'.$xml.'" '.$web_service;
exec($cmd, $result);
print_r($result); // Getting Null
方法二
$curlData = '<?xml version="1.0" encoding="utf-8"?><tasks><insertContact><contact uid="0"><salutation>Mr.</salutation><familyName>Smith</familyName><givenName>John</givenName><organisationName></organisationName></contact></insertContact></tasks>';
$url = https://secure.saasu.com/webservices/rest/r1/Tasks?wsaccesskey=XXXXXXXXXXXXXXXXX&FileUid=XXX';
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl,CURLOPT_HTTPHEADER,array (
'SOAPAction:""',
'Content-Type: text/xml; charset=utf-8',
));
curl_setopt ($curl, CURLOPT_POST, 1);
curl_setopt ($curl, CURLOPT_POSTFIELDS, $curlData);
$result = curl_exec($curl);
curl_close ($curl);
print_r($result); //NULL RESULT