步骤1
我正在使用 CURL 发送一个 xml 请求,并将其返回“ TOKEN ”给我。请在此处找到以下代码:
<root><request><type>mykey</type><username>myusername</username><password>mypassword</password></request></root>
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, $curl_url);// passing API URL here
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $xml_strign); // passing xml as a string
$result = curl_exec ($curl_handle);
在上面的代码中执行良好并返回Token作为结果。
第2步
在第二步中,我必须发送上面的令牌才能得到我的结果但没有得到结果。请找到以下代码:
$xml = "<root>
<request>
<type>myparam</type>
<token>lGcvdOnetuxK0paE+AIxE93GB85DURIpOeoBw8quqOs=</token>
</request>
</root>";
curl_setopt($curl_handle, CURLOPT_URL, $curl_url);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $xml);
$result = curl_exec ($curl_handle);
curl_close ($curl_handle);
print_r($result);
可能是这个令牌包含我猜的特殊章程,所以我没有得到结果。我在浏览器中看到控制台 url 响应状态为 200 ok。
我非常感谢您的帮助。