首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >fputs到卷曲

fputs到卷曲
EN

Stack Overflow用户
提问于 2011-02-19 08:12:47
回答 1查看 1.1K关注 0票数 0

我有这个脚本,它需要allow_url_fopen = On,这不是一个好主意,我想要更改curl。如果有人能帮我做fputs GET,我将不胜感激。

代码语言:javascript
复制
$SH = fsockopen($IP, $Port, $errno, $errstr, 30);
echo $errstr;    
#$ch = curl_init();
#curl_setopt($ch, CURLOPT_TIMEOUT, 30);
#curl_setopt($ch, CURLOPT_URL, $IP.":".$Port);
#curl_setopt ($ch, CURLOPT_HEADER, 0);
    if ($SH){ 
        fputs($SH,"GET /7.html HTTP/1.0\r\nUser-Agent: S_Status (Mozilla Compatible)\r\n\r\n");
        $content = "";
        while(!feof($SH)) { 
            $content .= fgets($SH, 1000);
            #content .= curl_setopt($ch, CURLOPT_FILE, $SH);
        }
        fclose($SH);
        #curl_close($ch);
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-02-19 08:53:40

如果我正确理解了您的问题,那么您只是在寻找如何发送HTTP请求(这就是您的fputs($SH, "GET ...")正在做的事情,这是使用curl_exec()完成的。看起来这应该行得通。

代码语言:javascript
复制
$ch = curl_init();
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_PORT, $Port);
curl_setopt($ch, CURLOPT_URL, $IP . '/7.html');
curl_setopt($ch, CURLOPT_USERAGENT, 'S_Status (Mozilla Compatible)'); 
//tell curl to return the output, not display it
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
//execute the request
$content = curl_exec($ch);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5047899

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档