开发者

Php Curl to Send XML Data By GET Params

开发者 https://www.devze.com 2023-02-05 02:18 出处:网络
i am trying to send an url 开发者_开发知识库encoded xml fields with curl. Is there another way send data except in url? Because i tried this but is throwed \"No URL set!\" error.

i am trying to send an url 开发者_开发知识库encoded xml fields with curl. Is there another way send data except in url? Because i tried this but is throwed "No URL set!" 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:

How about:

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

instead?

0

精彩评论

暂无评论...
验证码 换一张
取 消