开发者

Curl : Simultaneous GET and POST

I want to use curl to make a request which has both 开发者_JAVA技巧GET and POST variables? How do I do it.

My priliminary understanding tells me that the only way to send POST variables is if I make the CURL request type as POST using CURLOPT_POST. However, using this, any GET variables in the url I set for CURLOPT_URL are also converted to POST - is that correct?

How to do this correctly?

regards,

JP


any GET variables in the url I set for CURLOPT_URL are also converted to POST - is that correct?

No, I don't believe it is. The following code gives both GET and POST values:

<?php

$ch = curl_init();
curl_setopt_array($ch, array(
 CURLOPT_POST => true,
 CURLOPT_URL => 'http://localhost/test.php?getfield=text',
 CURLOPT_POSTFIELDS => array('postfield' => 'text2'),
 CURLOPT_RETURNTRANSFER => true
));

echo curl_exec($ch);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜