[英]How can I convert this cURL command to PHP?
The SSH command I'm currently using in Terminal is: 我当前在Terminal中使用的SSH命令是:
curl -L -b cookies.txt http://www.dropbox.com/s/8lu0nutt4tgpkku/jbtools.ipa -o iOS9_beta.ipsw
I first login to my developer account and then download the cookies by a Chrome extension; 我首先登录我的开发者帐户,然后通过Chrome扩展程序下载cookie; following that, I upload the cookies.txt file to the same path I run the SSH command and easily mirror the file to my server.
之后,我将cookies.txt文件上传到运行SSH命令的相同路径,并轻松地将该文件镜像到我的服务器。 Now, I would like to do the same job with a PHP script.
现在,我想使用PHP脚本执行相同的工作。 I tried this code but didn't work.
我尝试了这段代码,但是没有用。
<?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;
?>
Any help/ideas would be greatly appreciated 任何帮助/想法将不胜感激
UPDATE: I updated my code the below code but: 更新:我更新了下面的代码,但是:
$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;
Let's have a look whats missing in your curl. 让我们看看你的卷发中缺少什么。
-L = follow redirects -L =跟随重定向
curl_setopt($cSession, CURLOPT_FOLLOWLOCATION, true);
see: http://php.net/manual/en/function.curl-setopt.php 参见: http : //php.net/manual/en/function.curl-setopt.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.