[英]Cannot remote upload through openload API [PHP - curl]
I'm trying to upload a file using the openload API that can be found here . 我正在尝试使用可在此处找到的openload API上传文件。
When I upload some file I always get a JSON response of success (code: 200): 当我上传一些文件时,我总是得到成功的JSON响应 (代码:200):
Unfortunately when I check the file status (using both API and website) it tells me that there was an error in upload. 不幸的是,当我检查文件状态(同时使用API和网站)时,它告诉我上传错误。 Here the JSON response (code 200):
这是JSON响应 (代码200):
Here is how I send the request. 这是我发送请求的方式。 Where's the error?
错误在哪里? I tried using both the urlencode function and not.
我尝试同时使用urlencode函数。
$user = "...";
$psw = "...";
$link = urlencode("https://google.com/favicon.ico");
$url = "https://api.openload.co/1/remotedl/add?login=$user&key=$psw&url=$link";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_URL => $url,
CURLOPT_USERAGENT => 'Codular Sample cURL Request'
));
$resp = curl_exec($curl);
curl_close($curl);
echo $resp;
EDIT: Switched to https and added CURLOPT_FOLLOWLOCATION => true
, still no success. 编辑:切换到https并添加了
CURLOPT_FOLLOWLOCATION => true
,仍然没有成功。
I think you are hitting a http 301 redirect while using curl 我认为您在使用curl时遇到了HTTP 301重定向
http://google.com/favicon.ico
to 至
https://www.google.com/favicon.ico
If that case curl option CURLOPT_FOLLOWLOCATION might help. 如果是这种情况,则卷曲选项CURLOPT_FOLLOWLOCATION可能会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.