$post_data = array(
'url' => $all[2],
'op' => 'sv',
'sid' => 1
);
// Send a request to example.com
$result = post_request('http://www.yahoo.com', $post_data);
function PostRequest($url) {
$opts = array('http' =>
array(
'method' => 'GET',
'header' => "Content-type: application/x-www-form-urlencoded\r\n"."Accept-language: en\r\n" .
"Cookie: member_id=8593099\r\n" .
"Cookie: pass_hash=fad917fe75e1059f85fc6d9bb6f7a19f\r\n".
"Cookie: session_id=279fe56fd87e5371dc7e1c9f66c27522"
)
);
$context = stream_context_create($opts);
$result = file_get_contents($url, false, $context);
return $result;
}
我能够发送请求,但我的操作需要登录才能执行。 即使我登录,它也会将我归类为未登录。php http请求
我正在使用本地主机发送请求。那是因为不同的领域? 我已经复制了我的本地主机的登录cookie,但它仍然不起作用。 任何想法? 我试图做的是用PHP发送http请求。 我的请求已发出,但我的目的地无法检测到cookie,并声称我没有登录。
我发现很难理解你的问题。您是否尝试将发布数据发送到example.com,但它不起作用,因为example.com要求您登录? – Mike
'post_request' - 那个函数在做什么?除非你没有提供任何关于它的细节(你是否使用库/框架/ cms?),你的问题是无法回答的。此外,您可能会监督雅虎需要cookies进行登录。 – hakre