这是我的代码。
<?php
if(isset($_REQUEST['name']) and ($_REQUEST['email']) and ($_REQUEST['msg'])){
$name=$_REQUEST['name'];
$email= $_REQUEST['email'];
$msg = $_REQUEST['msg'];
$url="http://14.140.111.4:20002/ContactUs?name=$name&Email=$email&Message=$msg";
$url = urlencode($url);
$curl = curl_init();
// Set some options - we are passing in a useragent too here urlencode
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $url,
CURLOPT_USERAGENT => 'Cubewires Sample cURL Request',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => array(
'name'=>$name,
'Email' => $email,
'Message'=>$msg
)
));
// Send the request & save response to $resp
$resp = curl_exec($curl);
print_r($resp);
// Close request to clear up some resources
curl_close($curl);
}
?>
我收到HTTP错误400的响应。使用此API数据时应插入数据库中。 谢谢, 的Vivek