我的密码curl有时失败? [英] My password curl is failing sometimes?

查看:132
本文介绍了我的密码curl有时失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $PathUrl);
    curl_setopt($ch, CURLOPT_USERPWD, 'someuser:somepass');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $data = curl_exec($ch);
    $info = curl_getinfo($ch);

任何想法为什么它工作大约30%的时间和其他70%如果失败.. ..

Any ideas on why it works about 30% of the time and the other 70% if fails....viewing the url on any browser works all the time

推荐答案

你可以更好地设置授权标头通过 CURLOPT_HTTPHEADER

You may be better off setting the Authorization header via CURLOPT_HTTPHEADER.

例如, curl_setopt $ ch,CURLOPT_HTTPHEADER,array('Authorization'=>'user:pass'))

因为你说它工作在30%的时间,但只是意识到通常的形式编码的Auth头,例如base64。

also, this may not apply because you say it works 30% of the time, but just be aware of common forms of encoding for Auth headers, eg, base64.

这篇关于我的密码curl有时失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆