Sending OMA xml document with php..

Sending OMA xml document with php.. SearchSearch

SMS & MMS Technical Forum » NowSMS Support - SMS Issues (Product Support Only) » Archive through February 02, 2006 » Sending OMA xml document with php.. « Previous || Next »
Author Message
Chung
New member
Username: M3wil

Post Number: 1
Registered: 10-2005
Posted on Saturday, October 08, 2005 - 04:23 pm:   

Hi,

How do I send OMA/OTA using php script? Also, I don't use .ota file in the folder of NowSMS.. Is actually a web page where the admin will enter the xml format of the OMA/OTA file (such as Push to talk setting) then send using NowSMS.

I have created a form then allow the admin to enter the OMA xml settings, almost similar as the NowSMS web interface, "Send XML Document".

Another question, will the process be at server side (background) or at client side? BECAUSE the webserver is accessible from the internet, BUT the nowsms is installed in another server which is not accessible from internet. HOWEVER, the nowsms server only allow access from the webserver :-)

Thanks in advance!
Bryce Norwood - NowSMS Support
Board Administrator
Username: Bryce

Post Number: 5111
Registered: 10-2002
Posted on Tuesday, October 11, 2005 - 03:53 pm:   

Hi,

The process would be server side, so that will be fine for your architecture. Only the web server needs to be able to access NowSMS.

Basically, what you're going to want to do is a simple HTTP POST of the XML document.

From your script, you just need to open an HTTP connection to the port for the NowSMS web interface, and then you issue an HTTP POST:

POST /?PhoneNumber=xxxxxxxx&OTA=POST HTTP/1.0
Content-Length: yyyyyy
(*blank line*)
<xml settings document>

When submitting an OTA request in this manner, the HTTP POST request must include a “Content-Length:” header. This should match the length of your XML document.

NowSMS will scan the XML content to automatically determine what the content type is ... so that it can be encoded properly for sending over the air.

If you need to use a PIN on the settings, add "&OTAPIN=xxxx" to the URL, along with "&OTAPINTYPE=USERPIN" or "&OTAPINTYPE=NETWPIN".

-bn
Chung
New member
Username: M3wil

Post Number: 2
Registered: 10-2005
Posted on Monday, October 17, 2005 - 02:30 am:   

hello,

hmmm.. It is to no avail though.. when i click on the submit button to post, it doesn't seem to work.. I got a timeout error in return.
Bryce Norwood - NowSMS Support
Board Administrator
Username: Bryce

Post Number: 5159
Registered: 10-2002
Posted on Wednesday, October 19, 2005 - 03:17 pm:   

I'm sorry, but I don't understand what you mean.

When you click on what submit button?

If the submit button is triggering your PHP script, then it sounds like the "Content-Length:" header is not getting set properly.

When you perform an HTTP POST, the receiving server looks for the "Content-Length:" header, and this tells it how many bytes of data it should expect following the HTTP header.

You are likely seeing a timeout because the server is waiting for more data, based upon the value of this header.

If you're still stuck, post your PHP script, and maybe I can find some time to take a closer look at it.

-bn
Chung
New member
Username: M3wil

Post Number: 3
Registered: 10-2005
Posted on Thursday, October 20, 2005 - 03:40 am:   

This the PHP script..

<?php

//$PhoneNumber = $_POST['PhoneNumber'];
//$OTAPIN = $_POST['OTAPIN'];
//$xml = $_POST['OTAXMLSETTINGS'];
//$OTAPINTYPE = $_POST['OTAPINTYPE'];

$data = array();
$data["PhoneNumber"] = $_POST['PhoneNumber'];
$data["OTAXMLSETTINGS"] = $_POST['OTAXMLSETTINGS'];
$data["OTAPIN"] = $_POST['OTAPIN'];
$data["OTAPINTYPE"] = $_POST['OTAPINTYPE'];

$reqbody = "";
foreach($data as $key=>$val) {
$reqbody.= $key."=".urlencode($val);
$reqbody.= "&";
}

// INIT CURL
$ch = curl_init();

// SET URL FOR THE POST FORM LOGIN
curl_setopt($ch, CURLOPT_URL, 'http://<NOWSMS SERVER IP:8800');

// ENABLE HTTP POST
curl_setopt ($ch, CURLOPT_POST, 1);

// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD

curl_setopt ($ch, CURLOPT_POSTFIELDS, $reqbody);

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

// EXECUTE 1st REQUEST
$response = curl_exec ($ch);
echo $response;

curl_close($ch);
?>
Chung
New member
Username: M3wil

Post Number: 4
Registered: 10-2005
Posted on Wednesday, October 26, 2005 - 04:07 pm:   

hmmm? no reply?

Login Login / Register Logout Logout Search Last 30 Days Topics Topics