这是我的代码。第二个变量包含我想要发送到远程服务器的网址。任何人都可以帮助我吗?
<?php
$URLTOPOST="Here is my URL. where i send my data";
$DATATOPOST="http://localhost/newc/index.php";
$data=urlencode($DATATOPOST);
$ch=curl_init($URLTOPOST);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$returndata=curl_exec($ch);
echo $returndata;
curl_close($returndata);
?>
答案 0 :(得分:0)
你可以构建一个像这样的查询字符串
**http://www.yoururl.com?data=123&data1=xyz**
或者你可以使用CURL set选项发送像这样的帖子数据
curl_setopt($ch, CURLOPT_URL,"http://www.yoururl.com/index.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"var1=value1&var2=value2&var3=value3");