command line cURL with quote wrapped URL works, PHP cURL does not -


Then, I have an Amazon S3 encoded URL that I want to download. If I pass the URL without quotation marks, I get S3 to 403 forbidden response.

  curl-o https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/t/20141008/413f96bd17a210c0cfe2997d83a4782c/Nerve_Flossing_Highly_Irratible_Radial_Nerve_Wartenburgs_Syndrome-thumb.jpg?AWSAccessKeyId=AKIAI456JQ76GBU7FECA& ; Signature = Sd18YXJIMvLqeRFZYCzDNYdpg7U% 3D & amp; Expires = 1412866120   

But, just wrapping it in quotes, works great from the command line:

  curl-o "https: // zencoder -temp-storage-us-east-1.s3.amazonaws.com/t/20141008/413f96bd17a210c0cfe2997d83a4782c/Nerve_Flossing_Highly_Irratible_Radial_Nerve_Wartenburgs_Syndrome-thumb.jpg?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=Sd18YXJIMvLqeRFZYCzDNYdpg7U%3D&Expires=1412866120 "  

But ... when I try to implement it in PHP, I save the file with 0 bytes. $ curl = curl_init ("'" $ url. "' '); $ Fp = fopen ($ file path," W "); Curl_setopt ($ curl, CURLOPT_FILE, $ fp); Curl_XAC ($ curl); Curl_close ($ curl); fclose ($ FP);

Is there a way to do this with PHP which I do not remember? < p> Edit : To provide the real S3 URL for easy testing.

PHP cURL is just looking for a parameter when you add quotation to the command line, you are saying Whatever the difference between the quotation is the specific parameter that you are trying to pass in the command. Most command line commands work in this way. For example, if you move a file in the command line If you want, you can add path to the quote:

  mv foo.txt "/home/bar/foo.txt"   

This complex parameter (Eg URL), files with empty space in names, etc.

PHP For this, the curl function is only expecting one parameter and it is internally avoidable so when you add citations to the curl PHP command, you are actually asking PHP to load this URL:

  'https://some.amazon.bucket.s3.amazonaws.com/o/123456/582305890298509238/my-video.mp4?AWSAccessKeyId=RANDOMKEYHERE&Signature=SIG&Expires=1412805904'   

:

  https: //some.amazon.bucket.s3.amazonaws.com/o/123456/582305890298509238/my-video.mp4? AWSAccessKeyId = RANDOMKEYHERE & amp; Signature = SIG & Expires = 1412805904   

You mentioned that a quote Using it does not work in the command line curl Have you added any quotes in PHP? My guess is that this will work.

One more thing that you are tired is your S3 bucket is allowed. It is possible that the file you are trying to load from S3 does not have proper access permissions that allow PHP or your web server to access it. This will turn on a 403 error.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -