Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl to PHP -- Please Help

Status
Not open for further replies.

Lekoya

Programmer
Aug 4, 2006
6
ZA
Hi All,
I am busy re-developing an application in PHP the was previously written in Perl.
Can any body help me to have PHP script equivalent to the one below :

Code:
use LWP;
$addy = "[URL unfurl="true"]http://192.168.0.2/sms/auto/sendsms.cgi";[/URL]
$ua = new LWP::UserAgent;
$header = HTTP::Headers->new('username'=>'fusername','password'=>'fpwd','smstime'=>'0');	
$request = HTTP::Request->new('POST',"$addy",$header); 
$smsMessage = "You will be receiving your card in the post, your RefNo: $Ref! Your YourIdentity pin is: $PinCode.Login via [URL unfurl="true"]www.xyz.co.za.KEEP[/URL] THIS SMS";
$xml = "<?xml version=\"1.0\"?><sendsms><smscount>1</smscount><sms><msisdn>$ContactDetails</msisdn><message>$smsMessage</message></sms></sendsms>";
$request->content("$xml");
$response = $ua->request($request);
$reply_msg = $response->content
You help will higly appreciated
Regards
Lekoya
 
Hi,
Have a look at
--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Thank for timely response, but I have tried cUrl and it looks like it has limited options.

I dont know how to implement the following with cURL :
Code:
$header = HTTP::Headers->new('username'=>'fusername','password'=>'fpwd','smstime'=>'0');
This cURL code that I currently have.

Code:
$xml = "<?xml version=\"1.0\"?><sendsms><smscount>1</smscount><sms><msisdn>".$ContactDetails."</msisdn><message>".$smsMessage."</message></sms></sendsms>";
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, '[URL unfurl="true"]http://192.168.0.2/sms/auto/sendsms.cgi');[/URL]
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec ($ch);

// display the result
var_dump($response);
curl_close ($ch);

I also thought curl was an option but i am not sure what i am missing...

Please Help
 
set the option CURLOPT_HTTPHEADER with an array of HTTP headers. You can almost paste them from your Perl script.

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top