【发布时间】:2016-08-14 23:16:00
【问题描述】:
我目前在终端中使用的 SSH 命令是:
curl -L -b cookies.txt http://www.dropbox.com/s/8lu0nutt4tgpkku/jbtools.ipa -o iOS9_beta.ipsw
我首先登录我的开发者帐户,然后通过 Chrome 扩展程序下载 cookie;之后,我将 cookies.txt 文件上传到我运行 SSH 命令的同一路径,并轻松地将文件镜像到我的服务器。 现在,我想用 PHP 脚本做同样的工作。我试过这段代码,但没有用。
<?php
$cSession = curl_init();
curl_setopt($cSession,CURLOPT_URL,"http://www.dropbox.com/s/8lu0nutt4tgpkku/jbtools.ipa");
curl_setopt($cSession, CURLOPT_COOKIEJAR, 'cookies.txt');
curl_setopt($cSession, CURLOPT_COOKIEFILE, 'cookies.txt');
curl_setopt($cSession,CURLOPT_RETURNTRANSFER,true);
curl_setopt($cSession,CURLOPT_HEADER, false);
$result=curl_exec($cSession);
curl_close($cSession);
echo $result;
?>
任何帮助/想法将不胜感激
更新: 我用下面的代码更新了我的代码,但是:
- 如果我使用 CURLOPT_USERPWD 选项,我会得到“需要 401 授权”,尽管我定义了正确的用户并通过了
- 如果我使用 CURLOPT_COOKIEFILE 选项,我会得到“403 Forbidden”,尽管 cookies.txt 没有过期!
$cSession = curl_init();
curl_setopt($cSession,CURLOPT_URL,"http://adcdownload.apple.com/Safari/Safari_10_for_OS_X_El_Capitan_and_Yosemite_beta_5/Safari_10_for_OS_X_El_Capitan_beta_5.dmg");
curl_setopt($cSession, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($cSession, CURLOPT_USERPWD, "MyUser:MyPass");
// curl_setopt($cSession, CURLOPT_COOKIEJAR, 'cookies.txt');
//curl_setopt($cSession, CURLOPT_COOKIEFILE, 'cookies.txt');
curl_setopt($cSession,CURLOPT_RETURNTRANSFER,true);
curl_setopt($cSession,CURLOPT_HEADER, false);
$result=curl_exec($cSession);
curl_close($cSession);
echo $result;
【问题讨论】:
-
"I tried this code but didn't work."怎么没用?有没有错误?帮助我们在这里帮助你;-) -
完全没有错误信息。只是一个空白页:i-0s.ir/MyUD_ir/tst2.php
-
您分享的链接显示“未经授权”。请添加更多信息以帮助其他人了解您遇到的问题。
-
我在添加以下答案中提到的新行后收到此消息!