- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试将数据发送到使用 curl 并 try catch 数据的外部服务器。问题是响应数据是加密的,我认为问题出在 curl 和 SSL 上。我尝试使用 fiddler 进行捕获,当我解密数据时效果很好。我正在为 curl 使用一个类。代码如下:
class curl {
var $ch, $agent, $error, $info, $cookiefile, $savecookie;
function curl() {
$this->agent = $this->get_agent(rand(0,44));
$this->ch = curl_init();
curl_setopt ($this->ch, CURLOPT_USERAGENT, $this->agent);
curl_setopt ($this->ch, CURLOPT_HEADER, 1);
curl_setopt ($this->ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($this->ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($this->ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt ($this->ch, CURLOPT_FOLLOWLOCATION,true);
curl_setopt ($this->ch, CURLOPT_TIMEOUT, 30);
curl_setopt ($this->ch, CURLOPT_CONNECTTIMEOUT,30);
}
function timeout($time){
curl_setopt ($this->ch, CURLOPT_TIMEOUT, $time);
curl_setopt ($this->ch, CURLOPT_CONNECTTIMEOUT,$time);
}
function ssl($veryfyPeer, $verifyHost){
curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, $veryfyPeer);
curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, $verifyHost);
}
function header($header) {
curl_setopt ($this->ch, CURLOPT_HTTPHEADER, $header);
}
function login($user, $pass) {
curl_setopt ($this->ch, CURLOPT_USERPWD, "$user:$pass");
}
function cookies($cookie_file_path) {
$this->cookiefile = $cookie_file_path;;
$fp = fopen($this->cookiefile,'wb');fclose($fp);
curl_setopt ($this->ch, CURLOPT_COOKIEJAR, $this->cookiefile);
curl_setopt ($this->ch, CURLOPT_COOKIEFILE, $this->cookiefile);
}
function ref($ref) {
curl_setopt ($this->ch, CURLOPT_REFERER,$ref);
}
function socks($sock) {
curl_setopt ($this->ch, CURLOPT_HTTPPROXYTUNNEL, true);
curl_setopt ($this->ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt ($this->ch, CURLOPT_PROXY, $sock);
}
function proxy($sock) {
curl_setopt ($this->ch, CURLOPT_HTTPPROXYTUNNEL, true);
curl_setopt ($this->ch, CURLOPT_PROXY, $sock);
}
function post($url, $data , $hasHeader=true, $hasBody=true) {
curl_setopt($this->ch, CURLOPT_HEADER, $hasHeader ? 1 : 0);
curl_setopt($this->ch, CURLOPT_NOBODY, $hasBody ? 0 : 1);
curl_setopt($this->ch, CURLOPT_POST, 1);
curl_setopt($this->ch, CURLOPT_POSTFIELDS, $data);
return $this->getPage($url);
}
function data($url, $data, $hasHeader=true, $hasBody=true) {
curl_setopt ($this->ch, CURLOPT_POST, 1);
curl_setopt ($this->ch, CURLOPT_POSTFIELDS, http_build_query($data));
return $this->getPage($url, $hasHeader, $hasBody);
}
function get($url, $hasHeader=true, $hasBody=true) {
curl_setopt ($this->ch, CURLOPT_POST, 0);
return $this->getPage($url, $hasHeader, $hasBody);
}
function getPage($url, $hasHeader=true, $hasBody=true) {
curl_setopt($this->ch, CURLOPT_HEADER, $hasHeader ? 1 : 0);
curl_setopt($this->ch, CURLOPT_NOBODY, $hasBody ? 0 : 1);
curl_setopt ($this->ch, CURLOPT_URL, $url);
$data = curl_exec ($this->ch);
$this->error = curl_error ($this->ch);
$this->info = curl_getinfo ($this->ch);
return $data;
}
function close() {
unlink($this->cookiefile);
curl_close ($this->ch);
}
function get_agent($z){
switch ($z){
case 0: $agent= "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0"; break;
case 1: $agent= "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1"; break;
case 2: $agent= "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"; break;
case 3: $agent= "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"; break;
case 4: $agent= "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)"; break;
case 5: $agent= "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"; break;
case 6: $agent= "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9a8) Gecko/2007100619 GranParadiso/3.0a8"; break;
case 7: $agent= "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1b3) Gecko/20090305 Firefox/3.1b3"; break;
case 8: $agent= "Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4325)"; break;
case 9: $agent= "Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 6.0)"; break;
case 10: $agent= "Mozilla/4.0 (compatible; MSIE 5.5b1; Mac_PowerPC)"; break;
case 11: $agent= "Mozilla/4.0 (compatible; MSIE 7.0; AOL 9.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"; break;
case 12: $agent= "Mozilla/4.0 (compatible; MSIE 7.0; AOL 9.0; Windows NT 5.1; .NET CLR 1.1.4322; InfoPath.1; MS-RTC LM 8)"; break;
case 13: $agent= "Mozilla/4.0 (compatible; MSIE 7.0; AOL 9.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.0.04506.30)"; break;
case 14: $agent= "Mozilla/4.0 (compatible; MSIE 7.0; AOL 9.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; InfoPath.1)"; break;
case 15: $agent= "Mozilla/4.0 (compatible; MSIE 7.0; AOL 9.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)"; break;
case 16: $agent= "Mozilla/4.0 (compatible; MSIE 6.0; America Online Browser 1.1; rev1.5; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"; break;
case 17: $agent= "Mozilla/5.0 (X11; U; Linux; it-IT) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.4 (Change: 413 12f13f8)"; break;
case 18: $agent= "Mozilla/5.0 (X11; U; Linux; en-GB) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.3 (Change: 239 52c6958)"; break;
case 19: $agent= "Mozilla/5.0 (X11; U; Linux; en-US) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.2 (Change: 189 35c14e0)"; break;
case 20: $agent= "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; Avant Browser; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)"; break;
case 21: $agent= "Mozilla/5.0 (Windows; U; WinNT; en; rv:1.0.2) Gecko/20030311 Beonex/0.8.2-stable"; break;
case 22: $agent= "Mozilla/5.0 (X11; U; Linux x86_64; en-GB; rv:1.8.1b1) Gecko/20060601 BonEcho/2.0b1 (Ubuntu-edgy)"; break;
case 23: $agent= "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en; rv:1.8.1.4pre) Gecko/20070521 Camino/1.6a1pre"; break;
case 24: $agent= "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/419 (KHTML, like Gecko, Safari/419.3) Cheshire/1.0.ALPHA"; break;
case 25: $agent= "Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.0.1) Gecko/20021216 Chimera/0.6"; break;
case 26: $agent= "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/530.1 (KHTML, like Gecko) Chrome/2.0.164.0 Safari/530.1"; break;
case 27: $agent= "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.2; .NET CLR 2.0.50727; .NET CLR 1.1.4322; Crazy Browser 3.0.0 Beta2)"; break;
case 28: $agent= "Mozilla/5.0 (X11; U; Linux i686; en; rv:1.8.1.12) Gecko/20080208 (Debian-1.8.1.12-2) Epiphany/2.20"; break;
case 29: $agent= "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1b2pre) Gecko/20081015 Fennec/1.0a1"; break;
case 30: $agent= "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6b) Gecko/20031212 Firebird/0.7+"; break;
case 31: $agent= "Mozilla/5.0 (X11; U; Linux i686; it-IT; rv:1.9.0.2) Gecko/2008092313 Ubuntu/9.04 (jaunty) Firefox/3.5"; break;
case 32: $agent= "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9b3) Gecko/2008020514 Firefox/3.0b3"; break;
case 33: $agent= "Mozilla/5.0 (Windows; U; Windows NT 6.0; it; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9"; break;
case 34: $agent= "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.5) Gecko/20070713 Firefox/2.0.0.5"; break;
case 35: $agent= "Mozilla/4.76 [en] (X11; U; Linux 2.4.9-34 i686)"; break;
case 36: $agent= "Mozilla/4.75 [fr] (WinNT; U)"; break;
case 37: $agent= "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Opera 7.52 [en]"; break;
case 38: $agent= "Mozilla/4.0 (compatible; MSIE 6.0; ; Linux i686) Opera 7.50 [en]"; break;
case 39: $agent= "Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv:1.9.1b3pre) Gecko/20081212 Mozilla/5.0 (Windows; U; Windows NT 5.1; en) AppleWebKit/526.9 (KHTML, like Gecko) Version/4.0dp1 Safari/526.8"; break;
case 40: $agent= "Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.8.0.2) Gecko/20060309 SeaMonkey/1.0"; break;
case 41: $agent= "Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.7.6) Gecko/20050405 Epiphany/1.6.1 (Ubuntu) (Ubuntu package 1.0.2)"; break;
case 42: $agent= "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.5) Gecko/20060731 Firefox/1.5.0.5 Flock/0.7.4.1"; break;
case 43: $agent= "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/0.2.153.1 Safari/525.19 "; break;
case 44: $agent= "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5 "; break;
}
return $agent;
}
}
有人可以帮助我毫无问题地使用 curl 和 SSL 吗?
我正在尝试的主机的响应是这样的:
Fiddler 解码了,有什么问题吗?
最佳答案
尝试使用 gzip 编码:
curl_setopt($ch,CURLOPT_ENCODING, 'gzip');
如果还是不行,试试:
curl_setopt($ch,CURLOPT_ENCODING, '');
关于php - 在 PHP 上使用 SSL curl ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48876602/
我以前从未做过任何 curl ,所以需要一些帮助。我试图从示例中解决这个问题,但无法理解它! 我有一个 curl 命令,我可以从 Windows 命令行成功运行该命令,该命令行在 Solr 中索引 p
curl -v有什么区别和 curl -I ? 我可以看到 -v是冗长的和 -I是标题。有什么具体的吗? 最佳答案 -I (大写字母 i)在 curl 中表示“没有正文”,对于 HTTP 表示发送 H
我正在使用curl php API访问FTP链接。在特定站点上,它给出错误代码9(拒绝访问)。但是,可以从IE和Firefox访问该链接。 然后,我运行curl命令行,它给出了相同的“访问拒绝”结果。
我已经使用curl有一段时间了,它可以正常工作,但是使用使用用户'domain\username'来验证curl的代理时,无法请求授权。授权方法是NTLM。此代码放入批处理文件中。 代码: curl
“curl”默认使用哪些证书? 例子: curl -I -L https://cruises.webjet.com.au 在 Ubuntu 15.04 上失败 curl: (60) SSL certi
我知道终端输出的一部分是请求的持续时间,剩余时间等。但是是否有一些文档指定了curl命令的终端输出的每一列到底是什么?手册页上的内容非常稀疏。 最佳答案 可能不容易找到,但已在the curl boo
我想通过 curl 在我自己的云服务器上的特定文件夹中上传文件。例如:http://www.myowncloudserver.com/remote.php/webdav/{MY_FOLDER}。此时我
我的网站上有一个密码保护的Web文件夹,我正在使用Curl在另一个域上获取该文件夹,我想要的是:当我尝试打开URL时,应该问我用户名和密码,而不是让它显示“需要授权”。 例: http://www.e
有没有一种方法可以通过简单的Curl获取Rabbitmq中队列的大小(剩余消息)? 类似于curl -xget http://host:1234/api/queue/test/stats 谢谢 最佳答
关闭。这个问题是opinion-based .它目前不接受答案。 2年前关闭。 锁定。这个问题及其答案是locked因为这个问题是题外话,但具有历史意义。它目前不接受新的答案或互动。 我最近开始在我的
我想访问需要用户名/密码的 URL。我想尝试用curl 访问它。现在我正在做类似的事情: curl http://api.somesite.com/test/blah?something=123 我收
我正在尝试使用 CURL 进行查询ElasticSearch 中的命令在windows平台。 例如:localhost:9200/playground/equipment/1?pretty 我收到一条
我正在尝试使用 Docker 构建和运行 Marklogic 实例。 Marklogic 提供了一些不错的 http api,所以,作为最终 CMD在 Dockerfile 中,我运行两个脚本,它们通
我正在尝试通过 cURL 检索网页的内容(比方说 http://www.foo.com/bar.php )。 当我在浏览器中加载网站时,加载页面时会出现动画,页面最终会显示出来。 但是使用 cURL,
我正在尝试使用带代理的命令行 CURL 获取响应状态代码。 这会返回整个页面,但我只想要状态代码。我怎么做?谢谢。 curl -sL -w -x IP:PORT "%{http_code}\n""ht
我有一段代码检查 http/s 端点的状态和加载时间。然后我会为每个顶级页面检查 1 级 href,以检查页面引用的所有内容是否也加载了 200。 (我查了50个顶级页面,每个顶级页面平均有8个链接)
curl --upload-file 和 curl --form file=@/path/file 有什么区别?这些 HTTP 请求有何不同? 最佳答案 --上传文件 (使用 HTTP 或 HTTPS
我正在尝试使用 system-curl 安装 cmake,使用 ./bootstrap --system-curl,如 here 所示.这样做,我得到了: -- Could NOT find
我需要使用 Curl 下载 Youtube 视频的特定部分。 (假设我想下载前 2MB)我在 Curl 中使用 -r 开关来实现这一点。它适用于非 YouTube 链接,但 Youtube 链接会忽略
我希望在使用 curl 命令从远程服务器下载文件后,将时间戳或日期添加到文件名中。我知道您可以使用 -o 来指定您要为文件命名的内容。我看到过这样的建议:-o "somefile $(date +\"
我是一名优秀的程序员,十分优秀!