Last months on goText, Zydio was playing a lot with Qt and he has made a great application: goText++Desk, it’s awesome now you can use goText from your desktop… Anyway, that’s not all! He also has created an amazing XML system to create simple and advanced services to send SMS.
My today’s post is about how I has migrated the traditional php service to the new format
goText services requires two parts: a configuration and a sending part!
I will start telling about the configuration part, the old service required the next configuration:
<nu>0</nu><np>0</np><nn>1</nn><mr>1</mr><mc>110</mc><mm>20</mm><in>1</in>
</config>
It has 110 characters to send the SMS, It can send 20 sms per day, need a nick and got the title: Envia SMS con goText.
The configuration on the new format is done in two parts, firts we have some useful information as service name, help, max chars, version, icon, author and if it’s needed to save the session (this time it’s, remember the old script does
):
icon=”http://www.personal.com.ar/favicon.ico” author=”mesarpe”>
Then, we need to set how much recipients will have:
<recipient type=”phone” />
</recipients>
And then, how messages will be sent by day, which fields will be needed:
<field required=”true” name=”sender” description=”Nick” type=”txt” />
As you can see the configuration is so much clear now
Now it’s time of the sending part… If we remember a little bit we got two parts:
- Get the captcha code to fill
- Send the captcha code and all the values
We have not an if instruction but we have fork tags that makes some checks and they detects if we are on the first or second part. Take a look at the next example:
<condition type=”not_empty” var1=”$ic” ok_id=”4″ ko_id=”prepare_recipient” />
</fork>
It check if $ic variable is not empty then goes to page 4 (sending captcha code and sending the sms).
Another and the last thing to know! All the POST and GET connections now are made with some xml tags: the pages. The next example is the sending captcha and sms code, take a look at the var tag that makes some checks on the received page to see if the SMS has been sent:
<post name=”form_flag” value=”" />
<post name=”Snb” value=”$rcpt” />
<post name=”subname=” value=”$rcpt” />
<post name=”sig” value=”$sender” />
<post name=”msgtext” value=”$msg” />
<post name=”form” value=”ht4″ />
<post name=”size” value=”10″ />
<post name=”btn_send” value=”SEND” />
<post name=”historico” value=”" />
<post name=”Filename” value=”tmp/$captcha_filename.png” />
<post name=”FormValidar” value=”validar” />
<post name=”DE_MESG_TXT” value=”$sender” />
<post name=”sizebox” value=”43″ />
<post name=”MESG_TXT” value=”$msg” />
<post name=”codigo” value=”$ic” />
<post name=”Enviar.x” value=”41″ />
<post name=”Enviar.y” value=”16″ />
<post name=”pantalla” value=”" />
<var in=”page” name=”send_check” search=”match” match=”- a $rcpt” not_empty=”confirm” empty=”error” error_message=”Unknown send error on Personal website” />
</page>
Well… I know this is very incomplete I have not talked about variables and thousands of things that Zydio has created, but may be can help you to create your own service and it gives you a brief about the thing. On goText page we have a lot of documentation about it! You can see it.
The complete source code of the service is available on goText Sourceforge SVN Page.