How to send SMS via a 3rd party platform

How SMS work in asterCC

  • When you write SMS text and click [Send] button in asterCC, the system would save the message in table cc10_batchcontacts and cc10_batchcontact_archives.
  • Next, you need program a file and read the SMS record from database, send the message to the third party server by the request of the third party platform.
  • Finally, according to the return value from the third party, update the status value of the SMS data in the system, and mark if it has been sent successfully.

Data sheet

  • Sheet cc10_batchcontacts save the target phone number, sender’s account, and send status.
    • batchcontact_archive_id,Relate the data id of sheet cc10_batchcontact_archives to batchcontact_archive_id and the latter is for save the specific text of SMS.
    • target,The phone number of receivers.
    • status,The send status of SMS.
      • The original status is “new”, means a new one to be sent. And you system needs SMS like this and send them.
      • Once the SMS is being sending, please change the value into “pending” in the system.
      • When it is sent, change the status into “error”, “failed” or “success” according to the third party return value.
    • schedulertime,Preset the sending time, “0000-00-00 00:00:00”maens sending right now. And you can also set the sending time. The system would search the data field that is less than this time.
    • contacttime,The time to push the SMS to the third party. You can update the status field and the return value after the latter is been returned by the third party.
    • creby,The account of the SMS creator.
    • created,The time of the SMS’s creation.
    • error_msg,Add the reason here when the message sending result in failure or meet error.
    • responsenote,The reply message from the receiver, provided by the third party. When the system received the message, you can update in this field.
  • Sheet cc10_batchcontact_archives saves the actual text of the SMS to be sent.
  • Sheet cc10_batchcontacts relates the data within itself via the field “batchcontact_archive_id”.
    • archivetype: The message type.
    • content: The content of the SMS

php code demonstration

  • create a sms.php file, this demonstration is using a third party http API to send SMS. PHP code screenshot is on the below:
    • define variables

如何使用第三方短信平台发送短信_定义变量.jpg

  • Inquire the SMS to be sent from database, call function to send, and update the third party return value

如何使用第三方短信平台发送短信_处理数据.jpg

  • define the sending method

如何使用第三方短信平台发送短信_发送方法.jpg

  • set the execution cycle of this script
    • if you want to perform it every minute, you can add this file into “crontab -e” put “* * * * *”means perform it every minute.

如何使用第三方短信平台发送短信_执行周期.jpg

  • You can also make an infinite loops in the coding, and execute this php file in the server, making the program searching for the new SMS ceaselessly.

如何使用第三方短信平台发送短信_执行周期2.jpg

  • of course, you can execute this program through other ways. Just make sure you can find out the new SMS and send them to the third party server.

test the SMS sending in the system

  • login the agent platform, click the button to send SMS.

发送消息界面.jpg

  • Make sure it is the right message and click send, you will get the following tip:

发送提示.jpg

  • For the SMS to be sent and the failed ones, you can check them in Messages → Batchcontact

待发信息管理.jpg

  • If the SMS has been sent successfully, you can check them in Messages → Batchcontact Sent

已发信息管理.jpg

en/custom_development_guide/how_to_send_sms_via_a_3rd_party_platform.txt · Last modified: 2013/07/10 01:59 by menglj
Recent changes RSS feed Debian Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki