RFH : Send & Receive Data Via HTTP Header

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
eddiekl
Forum Newbie
Posts: 3
Joined: Wed May 18, 2005 11:58 pm

RFH : Send & Receive Data Via HTTP Header

Post 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.
hedge
Forum Contributor
Posts: 234
Joined: Fri Aug 30, 2002 10:19 am
Location: Calgary, AB, Canada

Post 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.
eddiekl
Forum Newbie
Posts: 3
Joined: Wed May 18, 2005 11:58 pm

Post 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
eddiekl
Forum Newbie
Posts: 3
Joined: Wed May 18, 2005 11:58 pm

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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
Post Reply