所以我想在这里做一个小的API。我只会通过头部发送一些信息(得到参数),我没有使用任何POST参数。 这是我写的代码。只需发送变量通过GET在cURL
function sendSMS($message, $number)
{
/*** Connection Params **/
/*** Build the request parameters ***/
$service="sms_api_call_receiver.php";
$number="1212";
$message="asas";
$result = sendPost("https://www.domain.com/smsapp/" . $service . "?message=".urlencode($message)."&number=".$number);
return $result;
}//function
function sendPost($Url)
{
// Initialisation
$ch=curl_init();
// Set parameters
curl_setopt($ch, CURLOPT_URL, $Url);
// Return a variable instead of posting it directly
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Active the POST method
//curl_setopt($ch, CURLOPT_POST, 1) ;
// Request
//curl_setopt($ch, CURLOPT_POSTFIELDS, $strRequest);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
// execute the connexion
$result = curl_exec($ch);
// Close it
//return curl_error($ch);
curl_close($ch);
return $result;
}
在接收文件,我有这样的代码: -
if(isset($_GET['message']))
{
return true;
}
else
{
return "12212";
}
但是当我测试,输出我得到的是: -
string '' (length=0)
我在做什么错在这里?
疑难解答 我试着看看curl_error
是否返回任何东西。但我什么都看不到。 这里的任何建议都会有所帮助。
'的var_dump($ _ GET)',确保这些参数通过在所有实际的到来。 – 2014-10-08 18:22:01