Page 1 of 1

RFH : Send & Receive Data Via HTTP Header

Posted: Thu May 19, 2005 12:46 am
by eddiekl
Hi,

I am trying to send & receive data via http header. Normally i use querystring (i'm from asp background), but the requirements comes from SMS gateway company, and my client want me to write in php.

Trying to understand how the header work, i wrote 2 php page, sender.php and receiver.php. The sender will carry customer data in the header, and receiver will capture and save this data into mysql database. After days of experimenting, i still couldnt figure out how to add the customer data into the sender.php headers and how to get the received header data in the receiver.php.

Here is the simple experimental codes.

sender.php

Code: Select all

<?php
header("AdditionalData1: This is the data");
header("Location: receiver.php");
?>

receiver.php

Code: Select all

<?php
print_r(headers_list());
?>
Sadly, the receiver just print out the x-powered thing instead of AdditionalData1 value.

I will appreciate any help. Thank you.

Posted: Thu May 19, 2005 10:21 am
by hedge
You have to understand what's happening. You aren't sending your custom header to the receiver.php script, you're sending it to the browser. The browser has no reason to pass that header along when it makes a request to the receiver.php script so you don't see it from there.

That's what cookies are for.

Posted: Thu May 19, 2005 8:20 pm
by eddiekl
This is the text from the API:
Interacting between R-ED Premio and service provider is performed by sending HTTP GET request to service provider URL and vice versa. After all the connectivity settings are configured service providers can send and receive SMS messages via HTTP. All parameters are sent in HTTP request headers.
From above text, is it correct that I need to use custom header? or the text just mean request parameter (http://url?data=value) instead of custom http header?. I'm a lil bit confused.

Hope somebody can help me to clarify this.

Thanks

Posted: Fri May 20, 2005 7:17 am
by eddiekl
Hi everyone,

I asked someone from yahoo Programming room, and he told me I can use Request. I havent try this yet. Hope this will work.

Thank you.

Posted: Fri May 20, 2005 7:29 am
by John Cartwright

Code: Select all

header(&quote;Location: receiver.php?data=thisissomedata&quote;);

Code: Select all

echo (isset($_GET&#1111;'data']) ? $_GET&#1111;'data'] : 'No Data Set');
you can also use sessions to pass data between pages