Gossamer Forum
Home : General : Perl Programming :

xml question

Quote Reply
xml question
hey, i am adding a sms text service on a website. the problem is that i am a novice at perl and know nothing about xml. i have been given the code below by the company who provide this service, but i dont know how to use it with perl.

i want a script to be called by a cron job, so the user never sees this script.
i have texted the xml in a normal html file and it worked, so how do i print it in perl?
also, is there any security issuses i should take into consideration.

thanks
Pedge

Code:
<form action="" method="post" name="test outbound" id="test outbound">
<textarea cols="70" rows="25" name="XML">
<?xml version="1.0" ?>
<SMSMessage>
<SMSAuthentication>
<Username></Username>
<Password></Password>
<AccountRef></AccountRef>
<ApplicationID></ApplicationID>
<ItemID></ItemID>
</SMSAuthentication>
<SMSMessageData>
<BillingAction></BillingAction>
<ShortCode></ShortCode>
<Originator></Originator>
<Operator></Operator>
<MC></MC>
<Recipient></Recipient>
<MessageType></MessageType>
<MessageText></MessageText>
<ControlData></ControlData>
<DeliveryReport></DeliveryReport>
<DeliveryDate></DeliveryDate>
<DeliveryTime></DeliveryTime>
</SMSMessageData>
</SMSMessage>
</textarea>
<input type="submit" value="Submit">
</form>
Quote Reply
Re: [pedge] xml question In reply to
I'd recommend having a play with XML::Simple. This is what I use to parse all the XML stuff I have ever had to do before, and it does the job great :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] xml question In reply to
thanks. can i ask. is that secure? i mean, would any user (excuting the script) be able to see my id + password?
Quote Reply
Re: [pedge] xml question In reply to
The user will only be able to see what you are outputting from the XML via your script.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] xml question In reply to
so basically the user will be able to see the code above? with my password in it? If so thats no good. any ideas?
would putting the script into a folder and hidding it or putting a password on the folder?
sorry like i said - novice at work...
Quote Reply
Re: [pedge] xml question In reply to
No, they won't be able to see it. As I said, all you do is pass the XML into XML::Simple, with something like;

use XML::Simple;
my $xml = XMLIn($xml_codes);

Then you can reference them with something like;

$xml->{SMZMessage}->{SMSMessageData}->{MessageType}

...or similar to that extent.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] xml question In reply to
ok - i have had a look at the docs, but there is one bit i dont quite understand...
once i have used XMLIn(), do i use XMLout() to send the request to the server to send my sms msg?

i put the following in one:
Code:
<SMSMessage>
<SMSAuthentication>
<Username>pedge</Username>
<Password>25GE11PE</Password>
<AccountRef></AccountRef>
<ApplicationID>1001</ApplicationID>
<ItemID></ItemID>
</SMSAuthentication>
<SMSMessageData>
<BillingAction>ZERO</BillingAction>
<ShortCode></ShortCode>
<Originator>TEXTFORCE</Originator>
<Operator></Operator>
<MC></MC>
<Recipient>447890540170</Recipient>
<MessageType>0</MessageType>
<MessageText>test sms message</MessageText>
<ControlData></ControlData>
<DeliveryReport></DeliveryReport>
<DeliveryDate></DeliveryDate>
<DeliveryTime></DeliveryTime>
</SMSMessageData>
</SMSMessage>
and then i created a perl script to process it:
Code:
use XML::Simple; my $xml = XMLin('params.xml');$xml->{SMSMessage};

not sure if thats correct, but how do i send it off to the url that would be used in the form?

thanks
Pedge
Quote Reply
Re: [pedge] xml question In reply to
use the data like this(if 'SMSMessage' is the root element):

Code:
use XML::Simple;
my $xml = XMLin('./params.xml');

if ($xml->{SMSAuthentication}->{'Username'} eq 'blah blah' and
$xml->{SMSAuthentication}->{'Password'} eq 'blah blah') {
print $xml->{SMSMessageData}->{'BillingAction'}, "\n";
print $xml->{SMSMessageData}->{'ShortCode'}, "\n";
print $xml->{SMSMessageData}->{'Originator'}, "\n";
......
}