/var/www/hkosl.com/b2b2c/webadmin/libraies/twilio/sdk/Services/Twilio/Rest/Messages.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php

class Services_Twilio_Rest_Messages extends Services_Twilio_ListResource {

    
/**
     * Create a new Message instance
     *
     * Example usage:
     *
     * .. code-block:: php
     *
     *      $client->account->messages->create(array(
     *          "Body" => "foo",
     *          "From" => "+14105551234",
     *          "To" => "+14105556789",
     *      ));
     *
     * :param array $params: a single array of parameters which is serialized and
     *      sent directly to the Twilio API. You may find it easier to use the
     *      sendMessage helper instead of this function.
     *
     */
    
public function create($params = array()) {
        return 
parent::_create($params);
    }

    
/**
     * Send a message
     *
     * .. code-block:: php
     *
     *      $client = new Services_Twilio('AC123', '123');
     *      $message = $client->account->messages->sendMessage(
     *          '+14105551234', // From a Twilio number in your account
     *          '+14105556789', // Text any number
     *          'Come at the king, you best not miss.'   // Message body (if any)
     *          array('https://demo.twilio.com/owl.png'),   // An array of MediaUrls
     *      );
     *
     * :param string $from: the from number for the message, this must be a
     *      number you purchased from Twilio
     * :param string $to: the message recipient's phone number
     * :param $mediaUrls: the URLs of images to send in this MMS
     * :type $mediaUrls: null (don't include media), a single URL, or an array
     *      of URLs to send as media with this message
     * :param string $body: the text to include along with this MMS
     * :param array $params: Any additional params (callback, etc) you'd like to
     *      send with this request, these are serialized and sent as POST
     *      parameters
     *
     * :return: The created :class:`Services_Twilio_Rest_Message`
     * :raises: :class:`Services_Twilio_RestException`
     *      An exception if the parameters are invalid (for example, the from
     *      number is not a Twilio number registered to your account, or is
     *      unable to send MMS)
     */
    
public function sendMessage($from$to$body null$mediaUrls null,
        
$params = array()
    ) {
        
$postParams = array(
            
'From' => $from,
            
'To' => $to,
        );
        
// When the request is made, this will get serialized into MediaUrl=a&MediaUrl=b
        
if (!is_null($mediaUrls)) {
            
$postParams['MediaUrl'] = $mediaUrls;
        }
        if (!
is_null($body)) {
            
$postParams['Body'] = $body;
        }
        return 
self::create($postParams $params);
    }
}