开发者

Sending httprequest from localhost

开发者 https://www.devze.com 2023-03-23 10:36 出处:网络
function PostRequest($url) { $opts = array(\'http\' => array( \'method\'=> \'POST\', \'header\'=> \'Cookie: testcookie=blah; testcookie2=haha;\'
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; 
}

After I sent out the cookies, I still return by a message non login. but when I surf the pages with browser, I am login. I sent request with localhost then I tried to used ajax to sent the r开发者_如何学编程equest, but return status 0......

Is there any way to sent out the request?


If you want to play with HTTP scripting, i have library which you can use. https://github.com/toopay/CI-Proxy-Library, its orriginally written for CodeIgniter, but with little tweak, you should can use it on any PHP script.

0

精彩评论

暂无评论...
验证码 换一张
取 消