简体   繁体   English

PHP卷曲以通过GET参数发送XML数据

[英]Php Curl to Send XML Data By GET Params

i am trying to send an url encoded xml fields with curl. 我正在尝试发送带有curl的url编码的xml字段。 Is there another way send data except in url? 除了网址以外,还有其他发送数据的方式吗? Because i tried this but is throwed "No URL set!" 因为我尝试了此操作,但被抛出“未设置URL!” error. 错误。

$ch = curl_init();

curl_setopt($ch, CURLOPT_HEADER, 1);

curl_setopt($ch, CURLOPT_URL, 'http://setmpos.ykb.com/PosnetWebService/XML');
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST /PosnetWebService/XML HTTP/1.1
Host: setmpos.ykb.com
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Pragma: nocache
Accept-Language: tr
Content-Type: application/x-www-form-urlencoded
Content-Length: ".strlen($url)."

$url");

$response = curl_exec($ch);

if (curl_errno($ch)) {
   $message = curl_error($ch);
}

For one, you're setting up a POST, but doing it via the custom handlers, when CURL's perfectly capable of doing a POST on its own, which means you're not really using a GET query: 一方面,您要设置POST,但是要通过自定义处理程序来执行此操作,而CURL完全有能力自己执行POST,这意味着您实际上并没有使用GET查询:

How about: 怎么样:

curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $array_of_fields_to_post);

instead? 代替?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM