TAILIEUCHUNG - Mobile Web Development phần 6

Bạn có thể gửi một tin nhắn kiểm tra bằng cách nhập địa chỉ URL trong trình duyệt của bạn và thay thế xxxx với các giá trị thích hợp. Hãy nhớ rằng tất cả các chi phí tin nhắn! Hầu hết các cổng sẽ cung cấp một số khoản tín dụng miễn phí hoặc giảm giá cho các tin nhắn thử nghiệm, | Sending Text Messages You can send a test message by entering the URL in your browser and replacing xxxx with proper values. Keep in mind that every message costs Most gateways will provide some free credits or discounted rates for test messages but the meter keeps running for every message you send Our meter for Luigi is also running so let us proceed with integrating the Clickatell API into the POTR code. We will first write a wrapper class to integrate with Clickatell. This will keep the integration distinct from other code and make it easier to manage changes. Essentially it will send GET requests and process the response. Here is how the API works for Clickatell To Authenticate and Get a Session Command http http auth api_id xxxx user xxxx password xxxx. Response OK Session ID or ERR Error number. To Send an SMS after Authenticating Command http http sendmsg session_id xxx x to xxxx text xxxx. Response ID apimsgid or ERR Error number Based on this let s write up our wrapper class. Time for Action Integrating with Clickatell to Send SMS Notifications 1. The first step in Clickatell integration is to authenticate and get a session ID. We can use this session ID in all further requests. Let us start our SMSGateway class with some basic variables and initialization functions. php class SMSGateway private apiURL private apiId private sessionId public lastCommand public lastResult public function __construct this- apiURL http http 104 Chapter 6 public function Init username password apiId this- apiId apiId params user username params password password params api_id this- apiId command auth if this- Request command params return true 2. The request function takes the name of the command and an array of parameters to pass. We will make a HTTP GET request to the Clickatell API URL and process the response string. The basic pattern of the response string is two parts separated by a colon. The first part is the .

TỪ KHÓA LIÊN QUAN
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.