2011-07-27 54 views
0
function PostRequest($url) { 
    $opts = array('http' => 
     array(
      'method' => 'POST', 
      'header' => 'Cookie: testcookie=blah; testcookie2=haha;' 
     ) 
    ); 

    //$context = stream_context_create($opts); 

    $context = stream_context_create($opts); 
    $result = file_get_contents($url, false, $context); 



    return $result; 
} 

在我發送了cookies之後,我仍然通過非登錄消息返回。但是當我用瀏覽器瀏覽網頁時,我登錄了。 我發送請求與本地主機然後我試圖用阿賈克斯發送請求,但返回狀態0 ......從本地主機發送httprequest

有沒有什麼辦法發出請求?

回答

0

如果你想玩HTTP腳本,我有你可以使用的庫。 https://github.com/toopay/CI-Proxy-Library,它原來爲CodeIgniter編寫,但幾乎沒有什麼調整,你可以在任何PHP腳本上使用它。

+0

thx,但我只是想發送cookie與file_get_contents.thx爲你的代碼^^ – Leon