473,788 Members | 3,078 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

reading Response Headers

Hi Group,
I am working on web service where I am trying to execute a
remote URL from within a php file and would like to make some
decisions depending on the output.

I am using fopen to open the URL
$handle=@fopen( "www.mysite .com/api/command","r");

If the command is successful it returns an XML file with
response headers. I have no problems reading the XML.

I am interested in the response header which has a session-ID.
how do I access this information.
any inputs are greatly appreciated..
Thanks a bunch,
Regards,
Ross

Nov 26 '05 #1
3 1599
ross wrote:
Hi Group,
...


I guess a socket connection will help you.

http://de3.php.net/fsockopen

Regards
Stefan
Nov 26 '05 #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

ross wrote:
I am interested in the response header which has a session-ID.
how do I access this information.


By using CURL functions to execute the HTTP query and grab the entire
results.

- --
- ----------------------------------
Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net

http://acm.asoc.fi.upm.es/~mr/ ; http://acm.asoc.fi.upm.es/~ivan/
MSN:i_********* *************** *@hotmail.com
Jabber:iv****** ***@jabber.org ; iv*********@kde talk.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDiGKl3jc Q2mg3Pc8RAmUMAJ 9LRLDlwL2UQJFWD gLUsTmU+B2vDQCe NiPi
7VRsczkuWWKJAQv EpyXL98s=
=g4+Q
-----END PGP SIGNATURE-----
Nov 26 '05 #3
VS
Stefan Rybacki wrote:
ross wrote:
Hi Group,
...

I guess a socket connection will help you.

http://de3.php.net/fsockopen


Here's an exmaple I found and use to get the last modified time of a
remote file:

function filemtime_remot e($uri)
{
$uri = parse_url($uri) ;
$uri['port'] = isset($uri['port']) ? $uri['port'] : 80;

// TimeOut
$tout = 5;
$handle = @fsockopen($uri['host'], $uri['port'], $errno, $errstr,
$tout);
if(!$handle)
return 0;

fputs($handle," HEAD $uri[path] HTTP/1.1\r\nHost: $uri[host]\r\n\r\n");
$result = 0;
while(!feof($ha ndle))
{
$line = fgets($handle,1 024);
if(!trim($line) )
break;

$col = strpos($line,': ');
if($col !== false)
{
$header = trim(substr($li ne,0,$col));
$value = trim(substr($li ne,$col+1));
if(strtolower($ header) == 'last-modified')
{
$result = strtotime($valu e);
break;
}
}
}
fclose($handle) ;
return $result;
}

$URL="http://www.xxxxx.com/filename.txt";
$tsrem = filemtime_remot e($URL);

--
VS
Nov 26 '05 #4

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

Similar topics

29
2725
by: VooDoo | last post by:
Hi, I have a Temperature sensor with internal web server that provide the data in a text format. When quering the ip(ttp://192.168.10.220/temp) of the sensor i get that kind of reply: Probe 1|82.2|Probe 2|80.8|Probe 3|-99.9|Probe 4|-99.9 I woud like to import the result into my mysql database. What is the best way to do this? Should i use a fopen() ? I have try with this but i don't know how get just the value data....
6
5450
by: _jpg_ | last post by:
Hi, I need to read (& store) all the custom response headers in an HttpResponse. I am writing an HttpModule and hence do not know what headers could have been added (but need to cache them for later use). The only relevant methods that I can see are AppendHeader/AddHeader(string, string) and ClearHeaders() both of which are obviously useless to me. Is there any way of reading the custom headers?
6
4326
by: Sam | last post by:
I have some issues with HTTP Headers and I was hoping for some pointers or references to good articles. Here is the problem. I have 6 .aspx pages, each page contains a common .ascx. This ascx serves two purposes, 1. it contains a tab strip with response.redirects to navigate to the other pages; 2. I authenticate the user by check to see if a cookie exists, if it doesn't I redirect to a login screen.
6
7390
by: john | last post by:
The standard method to transmit a file from an aspx page to a browser is to stream the file to the response then end the response. The HTML code generated by the aspx page is discarded, and the browser displays or offers to save the binary file instead. I would like to have the browser accept and display the revised HTML code as well as offering to open or save the attached file. This SHOULD be possible using a multipart MIME format -...
2
2050
by: ATS | last post by:
HOWTO Override ASP's Response output for 2003/IIS. Please help, I want to have an ASP page write back EVERYTHING to the ASP Response. That includes HTTP Headers. I want my ASP to look something like this: ========================================== <%@ Language=VBScript %> <%
2
2153
by: Paul Hale | last post by:
Hi, I have a c# application that I would like to read in a “somewebsite.url†file and extract the “Web document URL:†property for use in my app. Can anybody give me any pointers on how this can be done please? (If I crack it myself I will post the answer back here) Thanks,
3
7068
by: Alexander Smirnov | last post by:
I'm developing asp.net 2 web application and need to make a custom http handler which sometime must send response with "204 No Content" code. I set HttpResponse.Status="204 No Content"; But asp automatically adds headers such as "Content-Length: 0". This causes an error on the client. HttpResponse.ClearHeaders() doesn't help. How to make asp not to add headers (especially Content- Length)? Thanks in advance.
8
8754
by: Tony | last post by:
I've searched the web & can't find an answer to this. Is it possible to successfully use Response.AddHeader for a robots meta tag? For example, I want to do <% IF request("PageID") = 252 THEN Response.AddHeader "robots", "noindex" : %>
7
16927
by: mukeshrasm | last post by:
Hi I am no able to send mail and it is giving this error Warning: mail(): SMTP server response: 530 5.7.3 Client was not authenticated in c:\inetpub\wwwroot\eshop\includes\classes\email.php on line 522 and the code is: <?php /* $Id: email.php,v 1.12 2003/06/17 17:29:44 dgw_ Exp $
0
9655
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
9498
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
10172
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
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7517
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
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
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
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.