0
我想發送一個帖子請求到一個url,但它說這不是一個post請求。請幫助,這是我的代碼。發佈方法到遠程URL不工作在php
<?php
$url = "myurl";
$api = '{"Project-Key" : "string","MailFrom" : "email","From" : "email","To" : "email","Subject" : "Mail Subject","HtmlBody" : "<html><body> <img src="cid:naz.jpg"> </body> </html>"}';
$data = array(
"authtoken" => "token",
"scope" => "mail",
"mailDetails" => $api
);
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url,false, $context);
$result = json_decode($result, true);
print_r($result);
exit(0);
?>
看看PHP的捲曲功能,你應該使用它們發送POST請求。 http://php.net/manual/en/book.curl.php – AJReading