Я хочу отправить запрос POST с PHP.Мне нужно настроить в содержании две переменные.Также мне нужно указать два куки в заголовке.
Я пытался с stream_context_create и с curl_init без успеха.Например, вот мой код stream_context_create:
$url = "http://localhost/web/show_comments.php?id=$_GET[com_id]#";
$data = array('body' => "$_GET[comment]", 'userId' => "$_GET[spoof_id]");
$options = array(
'http' => array(
'header' => array("Content-type: application/x-www-form-urlencoded",
"Cookie: user=luis",
"Cookie: password:1234"),
'method' => 'POST',
'content' => http_build_query($data)
)
);
var_dump(http_build_query($data));
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) { /* Handle error */ }
var_dump($result);
com_id, spoof_id и комментарий - параметры, перехваченные в запросе GET.
Спасибо !!