大家好。
PHP and the Curl libraryIt can be easier/cleaner to use the curl library and set the CURLOPT_NETRC option.  With that option set,
curl will automatically scan the user's .netrc file for the login/password to the machine being referenced
in the request URL.$url = "http://xxxx.com?Feed=aa&query=ipod&num=10" \\
$c = curl_init($url);
curl_setopt($c, CURLOPT_NETRC, true);
 $s = curl_exec($c);
Then the .netrc entry would be:
     machine xxxx.com login
     feedlogin password feedpw各位,这是什么意思,怎么用?
With that option set,
curl will automatically scan the user's .netrc file for the login/password to the machine being referenced
in the request URL.  这句话什么意思?

解决方案 »

  1.   

    你用http协议,为什么要设CURLOPT_NETRC啊!难到你要做安全验证?CURLOPT_NETRC 选项为一个非零值,PHP将在你的 ~./netrc 文件中查找你要建立连接的远程站点的用户名及密码.netrc的格式为
    machine   机器名or IP
         login   登录名
         password  密码
      

  2.   

    找翻译来了……一旦设置了那个选项,curl会自动扫描用户的.netrc文件,寻找对应于请求的URL中引用到的机器的登陆名/密码。curl不熟悉,随便乱翻。
      

  3.   

    很简单.curl模仿post/get 提交登陆.
      

  4.   

    你用http协议,为什么要设CURLOPT_NETRC啊!难到你要做安全验证?CURLOPT_NETRC 选项为一个非零值,PHP将在你的 ~./netrc 文件中查找你要建立连接的远程站点的用户名及密码.netrc的格式为
    machine  机器名or IP
        login  登录名
        password  密码 
    是的,怎么登录呢?.netrc 在php中怎么应用呢?
      

  5.   

    好久以前用过curl库,c语言开发的(一个自动网页点击程序,其实不是点击,是分析链接内容,然后自动POST相应数据,自然涉及到认证问题),PHP也写过一些简单的比如POST数据之类的原来我也是看着CURL的文档一点一点琢磨出来的。
    如果是HTTP协议,要知道欲访问的URI是不是HTTP认证的(浏览器弹出对话框的那种),也有的是用POST数据(即网页上的表单);
    要根据不同方式编写不同的代码。curl库有一定的保持持续会话的能力,即一些登录数据能保持,直到curl会话结束。
     
    最好有实例,比如你的具体需求是什么。