Need Help in 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
dennislee85
Forum Newbie
Posts: 15
Joined: Mon Mar 12, 2007 9:16 pm

Need Help in HTTP Header

Post by dennislee85 »

hi,

i am trying to POST some info to a remote server which requires authentication. Below are the header and body style required by the remote server:

Code: Select all

POST /messaging.mobileway.com/yuuzoo_tes42477/yuuzoo_tes42477.sms HTTP/1.1
HOST: messaging.mobileway.com
Authorization: Basic dXNlcjpwYXNzd29yZA==
Content-Length: 160

Version=2.0
Subject=Test
[MSISDN]
List=+6593880590,+6591165669
[MESSAGE]
Text=TEST FROM DOS NUMBER 2
[SETUP]
OriginatingAddr=Yuuzoo
[END]
How i am gonna do with this? Below are my codes but somehow it is not working.

Code: Select all

$header = "POST /messaging.mobileway.com/yuuzoo_tes42477/yuuzoo_tes42477.sms HTTP/1.1<LF>\n";
	$header = $header."HOST: messaging.mobileway.com<LF>\n"."Authorization: Basic ".$authorize_login."<LF>";
	$header = $header."\nContent-Length: 160<LF>\n";
	//body
	$header = $header."\nVersion=2.0<LF>\n";
	$header = $header."Subject=Test<LF>\n";
	$header = $header."[MSISDN]\nList=+6593880590,+6591165669<LF>";
	$header = $header."\n[MESSAGE]\nText=TEST FROM DOS NUMBER 2<LF>\n";
	$header = $header."[SETUP]\nOriginatingAddr=Yuuzoo<LF>\n";
	$header = $header."[END]<LF>";
	
	$url = "http://messaging.mobileway.com/yuuzoo_tes42477/yuuzoo_tes42477.sms";
	$curl = curl_init();
	curl_setopt($curl, CURLOPT_URL, $url);
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);	
	curl_setopt($curl, CURLOPT_POST, 1);
	curl_setopt($curl, CURLOPT_VERBOSE, 1);	
	curl_setopt($curl, CURLOPT_POSTFIELDS,$header);
	$fwdresult = curl_exec($curl);
	
	curl_close($curl);
I was getting error response :

Code: Select all

Authorization Required
This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.
Even though the remote server had its firewall opened up for my access.

Please advise.

Thanks
User avatar
xpgeek
Forum Contributor
Posts: 146
Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:

Post by xpgeek »

How about authorization?
do you send username and password ?
dennislee85
Forum Newbie
Posts: 15
Joined: Mon Mar 12, 2007 9:16 pm

Post by dennislee85 »

yep.

Code: Select all

Authorization: Basic dXNlcjpwYXNzd29yZA==
This is a encoded username + password
Post Reply