我向SAASU发送请求以使用REST API创建新联系人,但我没有得到结果。 请帮帮我。
方法-1
$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
方式-2
$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
Saasu帮助:http://help.saasu.com/api/
答案 0 :(得分:0)
最后,得到了答复。这是代码
$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_URL, "http://www.php.net");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($curl, CURLOPT_POST, 1);
curl_setopt ($curl, CURLOPT_POSTFIELDS, $curlData);
$curl_response = curl_exec ($curl);
curl_close ($curl);
$xml = new SimpleXMLElement($curl_response);
print_r($xml);
由于