Re: [PHP] cURL functions

2005-05-13 Thread Chris Bruce
I did look at your post on PATH_INFO which did not get me any closer to  
the solution. At this point, I am just trying to get an image using  
cURL and then force it to download to the computer. Here is the link:

http://205.207.224.90/getimage.php
and here is the code:
header(Content-type: image/jpg);
Header('Content-Disposition: attachment;  
file=tigershippingdashboard20050429.jpg');
$ch = curl_init(); // create cURL handle (ch)
if (!$ch) {
  die(Couldn't initialize a cURL handle);
 }
// set some cURL options
$ret = curl_setopt($ch, CURLOPT_URL,  
http://images.apple.com/home/2005/images/ 
tigershippingdashboard20050429.jpg);
$ret = curl_setopt($ch, CURLOPT_HEADER, 1);
$ret = curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$ret = curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$ret = curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
$ret = curl_setopt($ch, CURLOPT_TIMEOUT, 30);

// execute
$ret = curl_exec($ch);
if (empty($ret)) {
// some kind of an error happened
die(curl_error($ch));
curl_close($ch); // close cURL handler
}
else {
$info = curl_getinfo($ch);
curl_close($ch); // close cURL handler
if (empty($info['http_code'])) {
die(No HTTP code was returned);
}
else {
// load the HTTP codes
// echo results
echo The server responded: br /;
print pre;
print_r($info);
print /pre;
  }
 }
I have tried changing the values of the curl options to no avail. What  
ends up happening is the the PHP file is what gets downloaded with all  
the binary data for the image in it. I need to find a way of getting  
just the image to download.

In this example, I just want the image  
tigershippingdashboard20050429.jpg to download.

Any ideas?
Thanks
Chris
If you want to support older browsers, on more platforms, you would do
well to look at another thread from yesterday where I talk about about
PATH_INFO.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] cURL functions

2005-05-13 Thread Jason Wong
On Friday 13 May 2005 23:19, Chris Bruce wrote:
 I did look at your post on PATH_INFO which did not get me any closer to
 the solution. At this point, I am just trying to get an image using
 cURL and then force it to download to the computer. Here is the link:

This should work:

 $ch = curl_init(); // create cURL handle (ch)
 if (!$ch) {
die(Couldn't initialize a cURL handle);
 }
 // set some cURL options
 $ret = curl_setopt($ch, CURLOPT_URL,
 http://images.apple.com/home/2005/images/
 tigershippingdashboard20050429.jpg);
 $ret = curl_setopt($ch, CURLOPT_HEADER, 0);
 $ret = curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
 $ret = curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 $ret = curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
 $ret = curl_setopt($ch, CURLOPT_TIMEOUT, 30);

 // execute
 $ret = curl_exec($ch);
 header(Content-type: image/jpg);
 Header('Content-Disposition: attachment;
 file=tigershippingdashboard20050429.jpg');
 echo $ret;


-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] cURL functions

2005-05-13 Thread Chris Bruce
This should work:
 $ch = curl_init(); // create cURL handle (ch)
 if (!$ch) {
die(Couldn't initialize a cURL handle);
 }
 // set some cURL options
 $ret = curl_setopt($ch, CURLOPT_URL,
 http://images.apple.com/home/2005/images/
 tigershippingdashboard20050429.jpg);
 $ret = curl_setopt($ch, CURLOPT_HEADER, 0);
 $ret = curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
 $ret = curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 $ret = curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
 $ret = curl_setopt($ch, CURLOPT_TIMEOUT, 30);
 // execute
 $ret = curl_exec($ch);
 header(Content-type: image/jpg);
 Header('Content-Disposition: attachment;
 file=tigershippingdashboard20050429.jpg');
 echo $ret;
Did you try this Jason? When I try it, it just downloads the 
getimage.php file with the binary content of the image in the file.

Chris

Re: [PHP] cURL functions

2005-05-13 Thread Jason Wong
On Saturday 14 May 2005 06:45, Chris Bruce wrote:
  This should work:

[code snipped]

 Did you try this Jason? 

Yes, I've tried the code that I posted (using my own URL for the image), 
works for me.

 When I try it, it just downloads the 
 getimage.php file with the binary content of the image in the file.

If by 'getimage.php' you mean the above, and you're getting the contents 
of the above (ie the raw PHP code) AND the binary content of the image 
then your webserver is seriously out of whack.

If you mean that the browser downloads the image binary data correctly BUT 
saves it in a file called 'getimage.php' then that is most likely a 
problem with your browser. Double check that you have 
Content-Disposition header correctly formatted, look at the user notes 
in the online manual for the header() function for loads of examples and 
suggestions. Also check the archives for Richard Lynch's posts where he 
rants (quite rightly) about IE's poor handling of forcing a download to 
be saved to file and ways to circumvent it.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] cURL functions

2005-05-13 Thread Richard Lynch
On Fri, May 13, 2005 3:45 pm, Chris Bruce said:
  header(Content-type: image/jpg);
  Header('Content-Disposition: attachment;
  file=tigershippingdashboard20050429.jpg');
  echo $ret;

 Did you try this Jason? When I try it, it just downloads the
 getimage.php file with the binary content of the image in the file.

Content-Disposition only works on some browsers.

The ONLY way to get EVERY browser to behave is to make your URL end in
tigershippingdashboard20050429.jpg -- and ideally to not have any other
extension (.php or .htm or .html or .shtml or ...) in the URL and also, if
you want it to work for various other multi-media (PDF, SWF, etc) you
might as well set up to use $_SERVER['PATH_INFO'] instead of $_GET

Whew.  That was my rant boiled down to one run-on sentence. :-)
HOW to do all that is in the archives with my name and PATH_INFO on it
most recently, though I really just stole all the bits and pieces from
everybody else.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] cURL functions

2005-05-12 Thread Chris Bruce
Hi,
I am connecting to a remote image download API using cURL functions. I 
have the connection working fine and am getting the response from the 
API. The problem is that the resulting image is being displayed as 
binary characters in the browser instead of downloading to my computer. 
Here is the code:

$ch = curl_init(); // create cURL handle (ch)
if (!$ch) {
  die(Couldn't initialize a cURL handle);
 }
// set some cURL options
$ret = curl_setopt($ch, CURLOPT_URL, path/to/api/with/vars/appended);
$ret = curl_setopt($ch, CURLOPT_HEADER, 0);
$ret = curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$ret = curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
$ret = curl_setopt($ch, CURLOPT_TIMEOUT, 30);
// execute
$ret = curl_exec($ch);
and here are the results from curl_getinfo:
Array
(
[url] = path/to/api/with/vars/appended
[http_code] = 200
[header_size] = 312
[request_size] = 242
[filetime] = -1
[ssl_verify_result] = 0
[total_time] = 0.298
[namelookup_time] = 0.013
[connect_time] = 0.013
[pretransfer_time] = 0.013
[size_upload] = 0
[size_download] = 750690
[speed_download] = 2519093.9597315
[speed_upload] = 0
[download_content_length] = 750690
[upload_content_length] = 0
)
Does anyone know how I can take the binary result and force it to 
download as a JPG image?

Thanks.
Chris


Re: [PHP] cURL functions

2005-05-12 Thread Jason Wong
On Friday 13 May 2005 02:54, Chris Bruce wrote:

 $ret = curl_setopt($ch, CURLOPT_HEADER, 0);

Try enabling the above or ...

 Does anyone know how I can take the binary result and force it to
 download as a JPG image?

... send an appropriate header before dumping the binary data.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] cURL functions

2005-05-12 Thread Richard Lynch
On Thu, May 12, 2005 11:54 am, Chris Bruce said:
 API. The problem is that the resulting image is being displayed as
 binary characters in the browser instead of downloading to my computer.

 Does anyone know how I can take the binary result and force it to
 download as a JPG image?

At a minimum, for current browsers, you need:
header(Content-type: image/jpeg);
before you send the JPEG out.

Actually, before you send *ANYTHING* out, but you'd break the JPEG sending
anything else out before that anyway.

If you want to support older browsers, on more platforms, you would do
well to look at another thread from yesterday where I talk about about
PATH_INFO.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Curl-functions + socket send and receive... where is thedocumenation ?

2003-01-17 Thread Stefan Vetter
I just need some documentation on how to get curl to send to and receive
from a socket. Since there is no such information on www.php.net/curl.

Anyone, who can help me with that ?


Stefan




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] CURL functions

2001-12-04 Thread Stefan Isarie

Hey,

I'm trying to use CURL for sending some headers to paypal. Can anyone tell 
me why this code below doesn't work as expected???

$ch = curl_init();

curl_setopt($ch, 
CURLOPT_URL,https://www.paypal.com/cgi-bin/webscr;);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 
cmd=_cartupdate=Update$vard=1);

curl_exec ($ch);
curl_close ($ch);

PS: $vard is defined.

Thanks in advance

Stefan - Romania

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] curl functions problems

2001-02-28 Thread Dezider Góra

Hi,

I have problem when using curl function to redirect to page. I use it
when I need to check for valid informations on the and because there are
passwords, I don't want to send it via GET in url. So I use curl to
redirect to the originating page. The script's name is saveplacer.php. I
use this code:
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL,"$HTTP_REFERER");
 curl_setopt($ch, CURLOPT_POST, 1);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $poststring = "placerid=$placerid"
.. "" . "pwd=$pwd" );
 curl_exec ($ch);
 curl_close ($ch);

Redirecting works, desired page shows up, but in browser's urlbar I get
http://mydomain/mysite/saveplacer.php and not
http://mydomain/mysite/add1.php as expected. I have checked the script
for empty spaces, headers, but nothing there. It shows the add1.php
script and url is different.
Has anyone experienced this?
I use Apache 1.3.17/PHP 4.0.4Pl1 on Windoze 2000 Pro. Even I don't think
it's anything to do with the problem.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]