473,783 Members | 2,418 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help on using curl

hi,
i wanted to accomplish these task:

1. from that webservice get a certain set of strings from the header
2. next, generate the image.

and these 2 steps will be done at the same time.

to get the header value:
$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $xmyurl);
curl_setopt($ch , CURLOPT_HEADER, 1);

ob_start();
curl_exec($ch);
$s=ob_get_conte nts();

now from the same url i want also to generate the image on the file.
if just to create the image:

$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $xmyurl);
curl_setopt ($ch, CURLOPT_CONNECT TIMEOUT, $timeout);
// Getting binary data
curl_setopt($ch , CURLOPT_RETURNT RANSFER, 1);
curl_setopt($ch , CURLOPT_BINARYT RANSFER, 1);

$image = curl_exec($ch);
curl_close($ch) ;

now...how to combine both functions?

Jul 2 '07 #1
2 1659
You could try CURLOPT_HEADERF UNCTION, example here:

http://www.php.net/manual/en/functio...topt.php#52675

On Jul 2, 5:08 am, shotokan99 <soft_devj...@y ahoo.comwrote:
hi,
i wanted to accomplish these task:

1. from that webservice get a certain set of strings from the header
2. next, generate the image.

and these 2 steps will be done at the same time.

to get the header value:
$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $xmyurl);
curl_setopt($ch , CURLOPT_HEADER, 1);

ob_start();
curl_exec($ch);
$s=ob_get_conte nts();

now from the same url i want also to generate the image on the file.
if just to create the image:

$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $xmyurl);
curl_setopt ($ch, CURLOPT_CONNECT TIMEOUT, $timeout);
// Getting binary data
curl_setopt($ch , CURLOPT_RETURNT RANSFER, 1);
curl_setopt($ch , CURLOPT_BINARYT RANSFER, 1);

$image = curl_exec($ch);
curl_close($ch) ;

now...how to combine both functions?

Jul 2 '07 #2
how to write a callback function that will simply get a custom field
from the header? if i run this code:
$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $xmyurl);
curl_setopt($ch , CURLOPT_HEADER, 1);

ob_start();
curl_exec($ch);
$s=ob_get_conte nts();
echo var_dump($s);

i get this result:
string(712) "HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Content-
Disposition: attachment; filename=5abe32 5176661.png ...."

now there are part of the string that i wanted to take..perhaps i can
use strpos,preg_mat ch...etc.


Jul 3 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3940
by: Jochen Daum | last post by:
Hi, I have to emulate a "file upload" to a Java Servlet which is done with the class URLConnection. The java source basically does URLConnection conn = theurl.openConnection("https://somesite"); w = conn.getOutputStream(); w.write(...)
2
4549
by: jimb | last post by:
I need some advice on how to securely transfer data between two servers. Here is the situation. We have two sql servers that hold student data. I have full access to my sql server, but only write access to the main sql server on campus. I hope to use XML and SSL to transfer student data to the main server. As for generating the XML, I'll have an asp.net page set up in a secure directory that will generate the data in xml format. The...
0
10712
by: mahesh anasuri | last post by:
Hi all, I am new to this mailing list. Thankful if any one is using curl/linux version to and worked on Https. I have created certificates (PEM format) for client and server using openSSL. I am using Apache server/Linux platform and started server with "server certificate". I configured server to listen HTTPS service at port 443. I downloaded download.txt correctly from server using command as $curl --cacert cacert.pem ...
0
5608
by: info | last post by:
Dear all, is the first time that I use SOAP, and i must say that i'm having several problems. this is SOAP message that expects the server =================XML EXPECTED FROM THE SERVER================ <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3
2637
by: Chuck Renner | last post by:
Please help! This MIGHT even be a bug in PHP! I'll provide version numbers and site specific information (browser, OS, and kernel versions) if others cannot reproduce this problem. I'm running into some PHP behavior that I do not understand in PHP 5.1.2. I need to parse the HTML from the following carefully constructed URI:
1
1646
by: devranger | last post by:
Hello, I am in the process of learning PHP CURL and in doing some test examples I am having some issues with CURL that I do not fully understand. I am doing a test to use CURL to post and return results from "http://powersports.honda.com/dealer_locator/dealer_locator.asp" However it does not appear to be returning results from the CURL post action. What CURL appears to be doing is finding the page...
9
2026
by: devranger | last post by:
I am using the below CURL Function and can not figure out why it is not retruning the results from the post. Can anyone take a look and tell me what I may be doing wrong? I am just not seeing it. As you can see at the bottom of the script if (strstr($Line, 'HOUSTON YAMAHA MOTORSPORTS')) then it is reading the correct page, otherwise if (strstr($Line, 'Yamaha Dealer Locator')) then it is reading the incorrect page of the initial URL...
1
4908
by: c1pkw | last post by:
Hi there, I’m having a real heap of trouble with PHP and cURL My aim is to use this code (or something like it) to submit 2 fields to a remote server (using GET) and receive back 6 fields (again with GET). When I run the function below, I get back a 401 unauthorized error although the Username and Password are correct. Presumably then, they are not reaching the remote server at all or in the correct state. Problem is, I know so...
3
2634
by: k.rollman | last post by:
I am having a problem using cURL to create an https connection on a non-standard port (440). Using curl_setopt to set the port to 440 has no effect, and I get the following from curl's verbose output. * About to connect() to xxx.xxx.xxx.xxx port 443 * Connected to xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx) port 443 If I put ':440' in the url, I get the following and an error code of 7. * About to connect() to xxx.xxx.xxx.xxx port 440
1
2358
by: sik of it | last post by:
I am using windows xp. Hi, I am really new to cURL (started today) and funnily enough haven't even got it to output anything yet! Anway my problem is when using the following code I always get an error number 7 which is "cURL error:Failed to connect to 209.249.24.13: Connection refused". I have tried this on plenty of websites and keep getting the same error with just different ip adresses. I am using WAMP5 Version 1.7.3 and have...
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.