Net_SMS
[ class tree: Net_SMS ] [ index: Net_SMS ] [ all elements ]

Source for file sms2email_http.php

Documentation is available at sms2email_http.php

  1. <?php
  2. /**
  3.  * Net_SMS_sms2email_http Class implements the HTTP API for accessing the
  4.  * sms2email (www.sms2email.com) SMS gateway.
  5.  *
  6.  * Copyright 2003-2005 Marko Djukic <marko@oblo.com>
  7.  *
  8.  * See the enclosed file COPYING for license information (LGPL). If you did
  9.  * not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  10.  *
  11.  * $Horde: framework/Net_SMS/SMS/sms2email_http.php,v 1.22 2004/04/29 16:23:48 mdjukic Exp $
  12.  *
  13.  * @author Marko Djukic <marko@oblo.com>
  14.  * @package Net_SMS
  15.  */
  16. class Net_SMS_sms2email_http extends Net_SMS {
  17.  
  18.     var $_base_url 'horde.sms2email.com/horde/';
  19.  
  20.     /**
  21.      * An array of capabilities, so that the driver can report which
  22.      * operations it supports and which it doesn't. Possible values are:<pre>
  23.      *   auth        - The gateway requires authentication before sending;
  24.      *   batch       - Batch sending is supported;
  25.      *   multi       - Sending of messages to multiple recipients is supported;
  26.      *   receive     - Whether this driver is capable of receiving SMS;
  27.      *   credit      - Is use of the gateway based on credits;
  28.      *   addressbook - Are gateway addressbooks supported;
  29.      *   lists       - Gateway support for distribution lists.
  30.      * </pre>
  31.      *
  32.      * @var array $capabilities 
  33.      */
  34.     var $capabilities = array('auth'        => false,
  35.                               'batch'       => 100,
  36.                               'multi'       => true,
  37.                               'receive'     => false,
  38.                               'credit'      => true,
  39.                               'addressbook' => true,
  40.                               'lists'       => true);
  41.  
  42.     /**
  43.      * This function does the actual sending of the message.
  44.      *
  45.      * @access private
  46.      *
  47.      * @param array $message  The array containing the message and its send
  48.      *                         parameters.
  49.      * @param string $to      The destination string.
  50.      *
  51.      * @return mixed  True on success or PEAR Error on failure.
  52.      */
  53.     function _send(&$message$to)
  54.     {
  55.         /* Set up the sending url. */
  56.         $url sprintf('postmsg.php?username=%s&password=%s&message=%s',
  57.                        urlencode($this->_params['user']),
  58.                        urlencode($this->_params['password']),
  59.                        urlencode($message['text']));
  60.  
  61.         /* Check if source from is set. */
  62.         if (!empty($message['send_params']['from'])) {
  63.             $url .= '&orig=' urlencode($message['send_params']['from']);
  64.         }
  65.         /* Check if message type is flash. */
  66.         if ($message['send_params']['msg_type'== 'SMS_FLASH'{
  67.             $url .= '&flash=1';
  68.         }
  69.         /* Check if delivery report url has been set. */
  70.         if (!empty($this->_params['delivery_report'])) {
  71.             $url .= '&dlurl=' urlencode($this->_params['delivery_report'].
  72.                     'reportcode=%code&destinationnumber=%dest';
  73.         }
  74.  
  75.         /* Loop through recipients and do some minimal validity checking. */
  76.         if (is_array($to)) {
  77.             foreach ($to as $key => $val{
  78.                 if (preg_match('/^.*?<?\+?(\d{7,})(>|$)/'$val$matches)) {
  79.                     $to[$key$matches[1];
  80.                 else {
  81.                     /* FIXME: Silently drop bad recipients. This should be
  82.                      * logged and/or reported. */
  83.                     unset($to[$key]);
  84.                 }
  85.             }
  86.             $to implode(','$to);
  87.         else {
  88.             if (preg_match('/^.*?<?\+?(\d{7,})(>|$)/'$to$matches)) {
  89.                 $to $matches[1];
  90.             else {
  91.                 return PEAR::raiseError(sprintf(_("Invalid recipient: '%s'")$to));
  92.             }
  93.         }
  94.  
  95.         /* Append the recipients of this message and call the url. */
  96.         $url .= '&to_num=' $to;
  97.         $response $this->_callURL($url);
  98.         if (is_a($response'PEAR_Error')) {
  99.             return $response;
  100.         }
  101.  
  102.         /* Parse the response, check for new lines in case of multiple
  103.          * recipients. */
  104.         $lines explode("\n"$response);
  105.         $response = array();
  106.  
  107.         if (count($lines> 1{
  108.             /* Multiple recipients. */
  109.             foreach ($lines as $line{
  110.                 $parts explode('To:'$line);
  111.                 $recipient trim($parts[1]);
  112.                 if ($lines[0== 'AQSMS-OK'{
  113.                     $response[$recipient= array(1null);
  114.                 else {
  115.                     $response[$recipient= array(0$lines[0]);
  116.                 }
  117.             }
  118.         else {
  119.             /* Single recipient. */
  120.             if ($lines[0== 'AQSMS-OK'{
  121.                 $response[$to= array(1null);
  122.             else {
  123.                 $response[$to= array(0$lines[0]);
  124.             }
  125.         }
  126.  
  127.         return $response;
  128.     }
  129.  
  130.     /**
  131.      * Returns the current credit balance on the gateway.
  132.      *
  133.      * @access private
  134.      *
  135.      * @return int  The credit balance available on the gateway.
  136.      */
  137.     function _getBalance()
  138.     {
  139.         /* Set up the url and call it. */
  140.         $url sprintf('postmsg.php?username=%s&password=%s&cmd=credit',
  141.                        urlencode($this->_params['user']),
  142.                        urlencode($this->_params['password']));
  143.         $response $this->_callURL($url);
  144.         if (is_a($response'PEAR_Error')) {
  145.             return $response;
  146.         }
  147.  
  148.         /* Try splitting up the response. */
  149.         $lines explode('='$response);
  150.  
  151.         if ($lines[0== 'AQSMS-CREDIT'{
  152.             return $lines[1];
  153.         else {
  154.             return $this->getError($lines[0]_("Could not check balance. %s"));
  155.         }
  156.     }
  157.  
  158.     /**
  159.      * Adds a contact to the gateway's addressbook.
  160.      *
  161.      * @access public
  162.      *
  163.      * @param string $name  The name for this contact
  164.      * @param int $number   The contact's phone number.
  165.      *
  166.      * @return mixed  The remote contact ID on success or PEAR Error on
  167.      *                 failure.
  168.      */
  169.     function addContact($name$number)
  170.     {
  171.         /* Set up the url and call it. */
  172.         $url sprintf('postcontacts.php?username=%s&password=%s&cmd=ADDCONTACT&name=%s&number=%s',
  173.                        urlencode($this->_params['user']),
  174.                        urlencode($this->_params['password']),
  175.                        urlencode($name),
  176.                        $number);
  177.         $response $this->_callURL($url);
  178.         if (is_a($response'PEAR_Error')) {
  179.             return $response;
  180.         }
  181.  
  182.         /* Check if there was an error response. */
  183.         if (substr($response017!= 'AQSMS-CONTACTIDOK'{
  184.             return $this->getError($response_("Could not add contact. %s"));
  185.         }
  186.  
  187.         /* Split up the response. */
  188.         $lines explode(',='$response);
  189.         return $lines[1];
  190.     }
  191.  
  192.     /**
  193.      * Updates a contact in the gateway's addressbook.
  194.      *
  195.      * @access public
  196.      *
  197.      * @param int $id       The contact's ID on the gateway.
  198.      * @param string $name  The name for this contact
  199.      * @param int $number   The contact's phone number.
  200.      *
  201.      * @return mixed  True on success or PEAR Error on failure.
  202.      */
  203.     function updateContact($id$name$number)
  204.     {
  205.         /* Set up the url and call it. */
  206.         $url sprintf('postcontacts.php?username=%s&password=%s&cmd=UPDATECONTACT&id=%s&name=%s&number=%s',
  207.                        urlencode($this->_params['user']),
  208.                        urlencode($this->_params['password']),
  209.                        $id,
  210.                        urlencode($name),
  211.                        $number);
  212.         $response $this->_callURL($url);
  213.         if (is_a($response'PEAR_Error')) {
  214.             return $response;
  215.         }
  216.  
  217.         /* Parse the response. */
  218.         if ($response == 'AQSMS-OK'{
  219.             return true;
  220.         else {
  221.             return $this->getError($response_("Could not update contact. %s"));
  222.         }
  223.     }
  224.  
  225.     /**
  226.      * Deletes a contact in the gateway's addressbook.
  227.      *
  228.      * @access public
  229.      *
  230.      * @param int $id  The contact's ID on the gateway.
  231.      *
  232.      * @return mixed  True on success or PEAR Error on failure.
  233.      */
  234.     function deleteContact($id)
  235.     {
  236.         /* Set up the url and call it. */
  237.         $url sprintf('postcontacts.php?username=%s&password=%s&cmd=DELETECONTACT&id=%s',
  238.                        urlencode($this->_params['user']),
  239.                        urlencode($this->_params['password']),
  240.                        $id);
  241.         $response $this->_callURL($url);
  242.         if (is_a($response'PEAR_Error')) {
  243.             return $response;
  244.         }
  245.  
  246.         /* Parse the response. */
  247.         if ($response == 'AQSMS-OK'{
  248.             return true;
  249.         else {
  250.             return $this->getError($response_("Could not delete contact. %s"));
  251.         }
  252.     }
  253.  
  254.     /**
  255.      * Fetches the entire address book from the gateway.
  256.      *
  257.      * @access public
  258.      *
  259.      * @return mixed  Array of contacts on success or PEAR Error on failure.
  260.      *                 Format of the returned contacts is for example:<code>
  261.      *                    array(<uniqueid> => array('name'   => <name>,
  262.      *                                              'number' => <number>),
  263.      *                          <uniqueid> => array('name'   => <name>,
  264.      *                                              'number' => <number>));
  265.      *  </code>
  266.      */
  267.     function getAddressBook()
  268.     {
  269.         /* Set up the url and call it. */
  270.         $url sprintf('postcontacts.php?username=%s&password=%s&cmd=GETADDRESSBOOK',
  271.                        urlencode($this->_params['user']),
  272.                        urlencode($this->_params['password']));
  273.         $response $this->_callURL($url);
  274.         if (is_a($response'PEAR_Error')) {
  275.             return $response;
  276.         }
  277.  
  278.         /* Check if there was an error response. */
  279.         if (substr($response019!= 'AQSMS-ADDRESSBOOKOK'{
  280.             return $this->getError($response_("Could not retrieve address book. %s"));
  281.         }
  282.  
  283.         /* Parse the response and construct the array. */
  284.         list($response$contacts_strexplode(','$response2);
  285.  
  286.         /* Check that the full address book list has been received. */
  287.         $length substr($response19);
  288.         if (strlen($contacts_str!= $length{
  289.             return PEAR::raiseError(_("Could not fetch complete address book."));
  290.         }
  291.         $contacts_lines explode("\n"$contacts_str);
  292.         $contacts = array();
  293.         /* Loop through lines and pick out the fields, make sure that the ""
  294.          * are not included in the values, so get the line less 1 char on each
  295.          * end and split for ",". */
  296.         foreach ($contacts_lines as $line{
  297.             list($id$name$numberexplode('","'substr($line1-1));
  298.             $contacts[$id= array('name' => $name'number' => $number);
  299.         }
  300.  
  301.         return $contacts;
  302.     }
  303.  
  304.     /**
  305.      * Creates a new distribution list on the gateway.
  306.      *
  307.      * @access public
  308.      *
  309.      * @param string $name    An arbitrary name for the new list.
  310.      * @param array $numbers  A simple array of numbers to add to the list.
  311.      *
  312.      * @return mixed  Gateway ID for the created list on success or PEAR Error
  313.      *                 on failure.
  314.      */
  315.     function listCreate($name$numbers)
  316.     {
  317.         /* Set up the url and call it. */
  318.         $url sprintf('postdistribution.php?username=%s&password=%s&cmd=ADDDISTLIST&name=%s&numlist=%s',
  319.                        urlencode($this->_params['user']),
  320.                        urlencode($this->_params['password']),
  321.                        urlencode($name),
  322.                        implode(','$numbers));
  323.         $response $this->_callURL($url);
  324.         if (is_a($response'PEAR_Error')) {
  325.             return $response;
  326.         }
  327.  
  328.         /* Check if there was an error response. */
  329.         if (substr($response016!= 'AQSMS-DISTITEMID'{
  330.             return $this->getError($response_("Could not create distribution list. %s"));
  331.         }
  332.  
  333.         /* Parse the response and get the distribution list ID. */
  334.         list($response$idexplode('='$response);
  335.  
  336.         /* TODO: do we need to check the length of the id string? */
  337.  
  338.         return $id;
  339.     }
  340.  
  341.     /**
  342.      * Deletes a distribution list from the gateway.
  343.      *
  344.      * @access public
  345.      *
  346.      * @param string $id  The gateway ID for the list to delete.
  347.      *
  348.      * @return mixed  True on success or PEAR Error on failure.
  349.      */
  350.     function listDelete($id)
  351.     {
  352.         /* Set up the url and call it. */
  353.         $url sprintf('postdistribution.php?username=%s&password=%s&cmd=DELETEDISTLIST&distid=%s',
  354.                        urlencode($this->_params['user']),
  355.                        urlencode($this->_params['password']),
  356.                        $id);
  357.         $response $this->_callURL($url);
  358.         if (is_a($response'PEAR_Error')) {
  359.             return $response;
  360.         }
  361.  
  362.         /* Check response. */
  363.         if ($response == 'AQSMS-OK'{
  364.             return true;
  365.         else {
  366.             return $this->getError($response_("Could not delete distribution list. %s"));
  367.         }
  368.     }
  369.  
  370.     /**
  371.      * Updates a distribution list on the gateway.
  372.      *
  373.      * @access public
  374.      *
  375.      * @param string $id       The gateway ID for the list to update.
  376.      * @param string $name     The arbitrary name of the list. If different
  377.      *                          from the original name that the list was created
  378.      *                          under, the list will be renamed.
  379.      * @param string $numbers  The new list of numbers in the list. If left
  380.      *                          empty, the result will be the same as calling
  381.      *                          the listRename() function.
  382.      *
  383.      * @return mixed  True on success or PEAR Error on failure.
  384.      */
  385.     function listUpdate($id$name$numbers = array())
  386.     {
  387.         /* Set up the url and call it. */
  388.         $url sprintf('postdistribution.php?username=%s&password=%s&cmd=UPDATELISTNAME&distid=%s&name=%s',
  389.                        urlencode($this->_params['user']),
  390.                        urlencode($this->_params['password']),
  391.                        $id,
  392.                        urlencode($name));
  393.  
  394.         /* Check if the list numbers need updating. */
  395.         if (!empty($numbers)) {
  396.             $url .= '&numbers=' implode(','$numbers);
  397.         }
  398.  
  399.         $response $this->_callURL($url);
  400.         if (is_a($response'PEAR_Error')) {
  401.             return $response;
  402.         }
  403.  
  404.         /* Check response. */
  405.         if ($response == 'AQSMS-OK'{
  406.             return true;
  407.         else {
  408.             return $this->getError($response_("Could not update distribution list. %s"));
  409.         }
  410.     }
  411.  
  412.     /**
  413.      * Renames a distribution list on the gateway. Does nothing other than
  414.      * calling the listUpdate() function with just the $id and $name
  415.      * variables.
  416.      *
  417.      * @access public
  418.      *
  419.      * @param string $id    The gateway ID for the list to update.
  420.      * @param string $name  The new arbitrary name for the list.
  421.      *
  422.      * @return mixed  True on success or PEAR Error on failure.
  423.      */
  424.     function listRename($id$name)
  425.     {
  426.         return $this->listUpdate($id$name);
  427.     }
  428.  
  429.     /**
  430.      * Fetches a listing of available distribution lists on the server.
  431.      *
  432.      * @access public
  433.      *
  434.      * @return mixed  An array of lists on success or PEAR Error on failure.
  435.      *                 Format of the returned lists is for example:<code>
  436.      *                    array(<uniqueid> => array('name'   => <name>),
  437.      *                          <uniqueid> => array('name'   => <name>));
  438.      *  </code>
  439.      */
  440.     function getLists()
  441.     {
  442.         /* Set up the url and call it. */
  443.         $url sprintf('postdistribution.php?username=%s&password=%s&cmd=GETCOMPACTLIST',
  444.                        urlencode($this->_params['user']),
  445.                        urlencode($this->_params['password']));
  446.         $response $this->_callURL($url);
  447.         if (is_a($response'PEAR_Error')) {
  448.             return $response;
  449.         }
  450.  
  451.         /* Check if there was an error response. */
  452.         if (substr($response022!= 'AQSMS-DISTRIBUTIONLIST'{
  453.             return $this->getError($response_("Could not retrieve distribution lists. %s"));
  454.         }
  455.  
  456.         /* Parse the response and construct the array. */
  457.         list($response$lists_strexplode(','$response2);
  458.  
  459.         /* Check that the full list of distribution lists has been received. */
  460.         $length substr($response22);
  461.         if (strlen($lists_str!= $length{
  462.             return PEAR::raiseError(_("Could not fetch the complete list of distribution lists."));
  463.         }
  464.         $lists_lines explode("\n"$lists_str);
  465.         $lists = array();
  466.         /* Loop through lines and pick out the fields, make sure that the ""
  467.          * are not included in the values, so get the line less 1 char on each
  468.          * end and split for ",". */
  469.         foreach ($lists_lines as $line{
  470.             list($id$name$countexplode('","'substr($line1-1));
  471.             $lists[$id= array('name'  => $name,
  472.                                 'count' => $count);
  473.         }
  474.  
  475.         return $lists;
  476.     }
  477.  
  478.     /**
  479.      * Fetches a specific distribution list from the gateway.
  480.      *
  481.      * @access public
  482.      *
  483.      * @param string  The ID of the distribution list to fetch.
  484.      *
  485.      * @return mixed  An array of numbers in the list on success or PEAR Error
  486.      *                 on failure.
  487.      */
  488.     function getList($id)
  489.     {
  490.         /* Set up the url and call it. */
  491.         $url sprintf('postdistribution.php?username=%s&password=%s&cmd=GETNUMBERSWITHID&distid=%s',
  492.                        urlencode($this->_params['user']),
  493.                        urlencode($this->_params['password']),
  494.                        $id);
  495.         $response $this->_callURL($url);
  496.         if (is_a($response'PEAR_Error')) {
  497.             return $response;
  498.         }
  499.  
  500.         /* Check if there was an error response. */
  501.         if (substr($response022!= 'AQSMS-DISTRIBUTIONLIST'{
  502.             return $this->getError($response_("Could not retrieve distribution list. %s"));
  503.         }
  504.  
  505.         /* Parse the response and construct the array. */
  506.         list($response$list_strexplode(','$response2);
  507.  
  508.         /* Check that the full list of distribution lists has been received. */
  509.         $length substr($response22);
  510.         if (strlen($list_str!= $length{
  511.             return PEAR::raiseError(_("Could not fetch complete distribution list."));
  512.         }
  513.         $list_str trim($list_str);
  514.         list($count$numbersexplode('","'$list_str);
  515.  
  516.         /* TODO: Anything useful that can be done with the count of numbers at
  517.          * the start? */
  518.         $count substr($count1);
  519.  
  520.         /* Explode the list of numbers into an array and return. */
  521.         $numbers substr($numbers0-1);
  522.         return explode(','$numbers);
  523.     }
  524.  
  525.     /**
  526.      * Identifies this gateway driver and returns a brief description.
  527.      *
  528.      * @access public
  529.      *
  530.      * @return array  Array of driver info.
  531.      */
  532.     function getInfo()
  533.     {
  534.         $info['name'_("sms2email via HTTP");
  535.         $info['desc'_("This driver allows sending of messages through the sms2email (http://sms2email.com) gateway, using the HTTP API");
  536.  
  537.         return $info;
  538.     }
  539.  
  540.     /**
  541.      * Returns the required parameters for this gateway driver. The settable
  542.      * parameters for this gateway are:<pre>
  543.      *   - user            - The username for authentication on the gateway;
  544.      *   - password        - The password for authentication on the gateway;
  545.      *   - ssl             - Whether or not to use SSL for communication with
  546.      *                       the gateway.
  547.      *   - delivery_report - A URL for a script which would accept delivery
  548.      *                       report from the gateway.
  549.      * </pre>
  550.      *
  551.      * @access public
  552.      *
  553.      * @return array  Array of required parameters.
  554.      */
  555.     function getParams()
  556.     {
  557.         $params = array();
  558.         $params['user']     = array('label' => _("Username")'type' => 'text');
  559.         $params['password'= array('label' => _("Password")'type' => 'text');
  560.         $params['ssl']      = array('label'    => _("Use SSL"),
  561.                                     'type'     => 'boolean',
  562.                                     'required' => false);
  563.         $params['delivery_report'= array('label'    => _("URL for your script delivery status report"),
  564.                                            'type'     => 'text',
  565.                                            'required' => false);
  566.                                             
  567.  
  568.         return $params;
  569.     }
  570.  
  571.     /**
  572.      * Returns the parameters that can be set as default for sending messages
  573.      * using this gateway driver and displayed when sending messages.
  574.      *
  575.      * @access public
  576.      *
  577.      * @return array  Array of parameters that can be set as default.
  578.      */
  579.     function getDefaultSendParams()
  580.     {
  581.         $params = array();
  582.         $params['from'= array(
  583.             'label' => _("Source address"),
  584.             'type' => 'text');
  585.  
  586.         $params['deliv_time'= array(
  587.             'label' => _("Delivery time"),
  588.             'type' => 'enum',
  589.             'params' => array(array('now' => _("immediate")'user' => _("user select"))));
  590.  
  591.         $types = array('SMS_TEXT' => 'SMS_TEXT''SMS_FLASH' => 'SMS_FLASH');
  592.         $params['msg_type'= array(
  593.             'label' => _("Message type"),
  594.             'type' => 'multienum',
  595.             'params' => array($types));
  596.  
  597.         return $params;
  598.     }
  599.  
  600.     /**
  601.      * Returns the parameters for sending messages using this gateway driver,
  602.      * displayed when sending messages. These are filtered out using the
  603.      * default values set up when creating the gateway.
  604.      *
  605.      * @access public
  606.      *
  607.      * @return array  Array of required parameters.
  608.      * @todo  Would be nice to use a time/date setup rather than minutes from
  609.      *         now for the delivery time. Upload field for ringtones/logos?
  610.      */
  611.     function getSendParams($params)
  612.     {
  613.         if (empty($params['from'])) {
  614.             $params['from'= array(
  615.                 'label' => _("Source address"),
  616.                 'type' => 'text');
  617.         }
  618.  
  619.         if ($params['deliv_time'== 'user'{
  620.             $params['deliv_time'= array(
  621.                 'label' => _("Delivery time"),
  622.                 'type' => 'int',
  623.                 'desc' => _("Value in minutes from now."));
  624.         }
  625.  
  626.         if (count($params['msg_type']> 1{
  627.             $params['msg_type'= array(
  628.                 'label' => _("Message type"),
  629.                 'type' => 'enum',
  630.                 'params' => array($params['msg_type']));
  631.         else {
  632.             $params['msg_type'$params['msg_type'][0];
  633.         }
  634.  
  635.         return $params;
  636.     }
  637.  
  638.     /**
  639.      * Returns a string representation of an error code.
  640.      *
  641.      * @access public
  642.      *
  643.      * @param int $error    The error code to look up.
  644.      * @param string $text  An existing error text to use to raise a
  645.      *                       PEAR Error.
  646.      *
  647.      * @return mixed  A textual message corrisponding to the error code or a
  648.      *                 PEAR Error if passed an existing error text.
  649.      *
  650.      * @todo  Check which of these are actually required and trim down the
  651.      *         list.
  652.      */
  653.     function getError($error$error_text '')
  654.     {
  655.         $error trim($error);
  656.  
  657.         /* An array of error codes returned by the gateway. */
  658.         $errors = array(
  659.             'AQSMS-NOAUTHDETAILS'        => _("No username and/or password sent."),
  660.             'AQSMS-AUTHERROR'            => _("Incorrect username and/or password."),
  661.             'AQSMS-NOMSG'                => _("No message supplied."),
  662.             'AQSMS-NODEST'               => _("No destination supplied."),
  663.             'AQSMS-NOCREDIT'             => _("Insufficient credit."),
  664.             'AQSMS-NONAMESUPPLIED'       => _("No name specified."),
  665.             'AQSMS-NONUMBERSUPPLIED'     => _("No number specified."),
  666.             'AQSMS-ADDRESSBOOKERROR'     => _("There was an error performing the specified address book function. Please try again later."),
  667.             'AQSMS-CONTACTIDERROR'       => _("The contact ID number was not specified, left blank or was not found in the database."),
  668.             'AQSMS-CONTACTUPDATEERROR'   => _("There was an error updating the contact details. Please try again later."),
  669.             'AQSMS-DISTIDERROR'          => _("The distribution list ID was either not specified, left blank or not found in the database."),
  670.             'AQSMS-NODISTLISTSUPPLIED'   => _("The distribution list was not specified."),
  671.             'AQSMS-INSUFFICIENTCREDITS'  => _("Insufficient credit to send to the distribution list."),
  672.             'AQSMS-NONUMBERLISTSUPPLIED' => _("Numbers not specified for updating in distribution list."),
  673.             'AQSMS-DISTLISTUPDATEERROR'  => _("There was an error updating the distribution list. Please try again later."));
  674.  
  675.         if (empty($error_text)) {
  676.             return $errors[$error];
  677.         else {
  678.             return PEAR::raiseError(sprintf($error_text$errors[$error]));
  679.         }
  680.     }
  681.  
  682.     /**
  683.      * Do the http call using a url passed to the function.
  684.      *
  685.      * @access private
  686.      *
  687.      * @param string $url  The url to call.
  688.      *
  689.      * @return mixed  The response on success or PEAR Error on failure.
  690.      */
  691.     function _callURL($url)
  692.     {
  693.         $options['method''POST';
  694.         $options['timeout'= 5;
  695.         $options['allowRedirects'= true;
  696.  
  697.         $url ($this->_params['ssl''https://' 'http://'$this->_base_url $url;
  698.  
  699.         if (!@include_once 'HTTP/Request.php'{
  700.             return PEAR::raiseError(_("Missing PEAR package HTTP_Request."));
  701.         }
  702.         $http &new HTTP_Request($url$options);
  703.         @$http->sendRequest();
  704.         if ($http->getResponseCode(!= 200{
  705.             return PEAR::raiseError(sprintf(_("Could not open %s.")$url));
  706.         }
  707.  
  708.         return $http->getResponseBody();
  709.     }
  710.  
  711. }

Documentation generated on Mon, 11 Mar 2019 14:21:09 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.