如何使用curl创建prestashop web服务资源?
到目前为止,我通过设置订单状态来使用curl的prestashop,但客户希望我从订单状态更改请求的来源,即请求发送方,向他提供信息。为此,我认为我需要创建一个prestashop资源,以便在两个不同的商店中设置更改订单状态的人的姓名。但是正如我所说的,使用文档中解释的代码无法成功地使用web服务。下面是我定义用于设置订单状态的curl代码的示例:如何使用curl创建prestashop web服务资源?,prestashop,Prestashop,到目前为止,我通过设置订单状态来使用curl的prestashop,但客户希望我从订单状态更改请求的来源,即请求发送方,向他提供信息。为此,我认为我需要创建一个prestashop资源,以便在两个不同的商店中设置更改订单状态的人的姓名。但是正如我所说的,使用文档中解释的代码无法成功地使用web服务。下面是我定义用于设置订单状态的curl代码的示例: $url3=$url."/api/orders/".Configuration::get('id_order'); $ch3
$url3=$url."/api/orders/".Configuration::get('id_order');
$ch3 = curl_init();
$test=curl_setopt($ch3, CURLOPT_URL, $url3);
$test2=curl_setopt($ch3, CURLOPT_RETURNTRANSFER, true);
$test3=curl_setopt($ch3, CURLOPT_HTTPGET, true);
$test4=curl_setopt($ch3, CURLOPT_SSL_VERIFYPEER, false);
$test5= curl_setopt($ch3, CURLOPT_HEADER, 1);
$test6=curl_setopt($ch3, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch3, CURLOPT_VERBOSE, true);
curl_setopt($ch3, CURLOPT_USERPWD, $username . ":" . $password);
$data= $result_response = curl_exec($ch3);
$this->writeInLogFile($result_response,'INFO');
// $this->writeInLogFile($data,'INFO');
$header_size=curl_getinfo($ch3,CURLINFO_HEADER_SIZE);
$header2=substr($result_response,0,$header_size);
$body=substr($result_response,$header_size+38);
$xml = simplexml_load_string($body);
$strings = $xml->xpath("//order");
foreach ($strings as $string) {
$string->current_state = $id_order_state;
}
$data2=substr($xml->asXML(),21);
//$this->writeInLogFile($data2,'INFO');
$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_CUSTOMREQUEST, 'PUT');
$test=curl_setopt($ch2, CURLOPT_URL, $url2);
$test2=curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
$test4=curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, false);
$test5= curl_setopt($ch2, CURLOPT_HEADER, 1);
$test6=curl_setopt($ch2, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch2, CURLOPT_POSTFIELDS, $data2);
curl_setopt($ch2, CURLOPT_VERBOSE, true);
curl_setopt($ch2, CURLOPT_USERPWD, $username . ":" . $password);
$result_response2 = curl_exec($ch2);
$this->writeInLogFile($result_response2,'INFO');
curl_close($ch3);
curl_close($ch2);
这是资源的prestashop文档
如果作为解决方案的一部分,我在这个推理上没有错,你能给我一个解决创造资源问题的方案吗