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
  4.  * the sms2email (www.sms2email.com) SMS gateway.
  5.  *
  6.  * Copyright 2003-2004 Marko Djukic <marko@oblo.com>
  7.  *
  8.  * See the enclosed file COPYING for license information (LGPL). If you did not
  9.  * receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  10.  *
  11.  * $Horde: framework/Net_SMS/SMS/sms2email_http.php,v 1.23 2004/04/29 16:38:52 mdjukic Exp $
  12.  *
  13.  * @author Marko Djukic <marko@oblo.com>
  14.  * @version $Revision: 1.23 $
  15.  * @package Net_SMS
  16.  */
  17. class Net_SMS_sms2email_http extends Net_SMS {
  18.  
  19.     var $_base_url 'horde.sms2email.com/horde/';
  20.  
  21.     /**
  22.      * An array of capabilities, so that the driver can report which operations
  23.      * it supports and which it doesn't. Possible values are:
  24.      *   auth        - The gateway requires authentication before sending;
  25.      *   batch       - Batch sending is supported;
  26.      *   multi       - Sending of messages to multiple recipients is supported;
  27.      *   receive     - Whether this driver is capable of receiving SMS;
  28.      *   credit      - Is use of the gateway based on credits;
  29.      *   addressbook - Are gateway addressbooks supported;
  30.      *   lists       - Gateway support for distribution lists.
  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:
  261.      *                    array(<uniqueid> => array('name'   => <name>,
  262.      *                                              'number' => <number>),
  263.      *                          <uniqueid> => array('name'   => <name>,
  264.      *                                              'number' => <number>));
  265.      */
  266.     function getAddressBook()
  267.     {
  268.         /* Set up the url and call it. */
  269.         $url sprintf('postcontacts.php?username=%s&password=%s&cmd=GETADDRESSBOOK',
  270.                        urlencode($this->_params['user']),
  271.                        urlencode($this->_params['password']));
  272.         $response $this->_callURL($url);
  273.         if (is_a($response'PEAR_Error')) {
  274.             return $response;
  275.         }
  276.  
  277.         /* Check if there was an error response. */
  278.         if (substr($response019!= 'AQSMS-ADDRESSBOOKOK'{
  279.             return $this->getError($response_("Could not retrieve address book. %s"));
  280.         }
  281.  
  282.         /* Parse the response and construct the array. */
  283.         list($response$contacts_strexplode(','$response2);
  284.  
  285.         /* Check that the full address book list has been received. */
  286.         $length substr($response19);
  287.         if (strlen($contacts_str!= $length{
  288.             return PEAR::raiseError(_("Could not fetch complete address book."));
  289.         }
  290.         $contacts_lines explode("\n"$contacts_str);
  291.         $contacts = array();
  292.         /* Loop through lines and pick out the fields, make sure that the ""
  293.          * are not included in the values, so get the line less 1 char on each
  294.          * end and split for ",". */
  295.         foreach ($contacts_lines as $line{
  296.             list($id$name$numberexplode('","'substr($line1-1));
  297.             $contacts[$id= array('name' => $name'number' => $number);
  298.         }
  299.  
  300.         return $contacts;
  301.     }
  302.  
  303.     /**
  304.      * Creates a new distribution list on the gateway.
  305.      *
  306.      * @access public
  307.      *
  308.      * @param string $name     An arbitrary name for the new list.
  309.      * @param array  $numbers  A simple array of numbers to add to the list.
  310.      *
  311.      * @return mixed  Gateway ID for the created list on success or PEAR Error
  312.      *                 on failure.
  313.      */
  314.     function listCreate($name$numbers)
  315.     {
  316.         /* Set up the url and call it. */
  317.         $url sprintf('postdistribution.php?username=%s&password=%s&cmd=ADDDISTLIST&name=%s&numlist=%s',
  318.                        urlencode($this->_params['user']),
  319.                        urlencode($this->_params['password']),
  320.                        urlencode($name),
  321.                        implode(','$numbers));
  322.         $response $this->_callURL($url);
  323.         if (is_a($response'PEAR_Error')) {
  324.             return $response;
  325.         }
  326.  
  327.         /* Check if there was an error response. */
  328.         if (substr($response016!= 'AQSMS-DISTITEMID'{
  329.             return $this->getError($response_("Could not create distribution list. %s"));
  330.         }
  331.  
  332.         /* Parse the response and get the distribution list ID. */
  333.         list($response$idexplode('='$response);
  334.  
  335.         /* TODO: do we need to check the length of the id string? */
  336.  
  337.         return $id;
  338.     }
  339.  
  340.     /**
  341.      * Deletes a distribution list from the gateway.
  342.      *
  343.      * @access public
  344.      *
  345.      * @param string $id  The gateway ID for the list to delete.
  346.      *
  347.      * @return mixed  True on success or PEAR Error on failure.
  348.      */
  349.     function listDelete($id)
  350.     {
  351.         /* Set up the url and call it. */
  352.         $url sprintf('postdistribution.php?username=%s&password=%s&cmd=DELETEDISTLIST&distid=%s',
  353.                        urlencode($this->_params['user']),
  354.                        urlencode($this->_params['password']),
  355.                        $id);
  356.         $response $this->_callURL($url);
  357.         if (is_a($response'PEAR_Error')) {
  358.             return $response;
  359.         }
  360.  
  361.         /* Check response. */
  362.         if ($response == 'AQSMS-OK'{
  363.             return true;
  364.         else {
  365.             return $this->getError($response_("Could not delete distribution list. %s"));
  366.         }
  367.     }
  368.  
  369.     /**
  370.      * Updates a distribution list on the gateway.
  371.      *
  372.      * @access public
  373.      *
  374.      * @param string $id                The gateway ID for the list to update.
  375.      * @param string $name              The arbitrary name of the list. If
  376.      *                                   different from the original name that
  377.      *                                   the list was created under, the list
  378.      *                                   will be renamed.
  379.      * @param optional string $numbers  The new list of numbers in the list.
  380.      *                                   If left empty, the result will be the
  381.      *                                   same as calling the listRename()
  382.      *                                   function.
  383.      *
  384.      * @return mixed  True on success or PEAR Error on failure.
  385.      */
  386.     function listUpdate($id$name$numbers = array())
  387.     {
  388.         /* Set up the url and call it. */
  389.         $url sprintf('postdistribution.php?username=%s&password=%s&cmd=UPDATELISTNAME&distid=%s&name=%s',
  390.                        urlencode($this->_params['user']),
  391.                        urlencode($this->_params['password']),
  392.                        $id,
  393.                        urlencode($name));
  394.  
  395.         /* Check if the list numbers need updating. */
  396.         if (!empty($numbers)) {
  397.             $url .= '&numbers=' implode(','$numbers);
  398.         }
  399.  
  400.         $response $this->_callURL($url);
  401.         if (is_a($response'PEAR_Error')) {
  402.             return $response;
  403.         }
  404.  
  405.         /* Check response. */
  406.         if ($response == 'AQSMS-OK'{
  407.             return true;
  408.         else {
  409.             return $this->getError($response_("Could not update distribution list. %s"));
  410.         }
  411.     }
  412.  
  413.     /**
  414.      * Renames a distribution list on the gateway. Does nothing other than
  415.      * calling the listUpdate() function with just the $id and $name 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:
  436.      *                    array(<uniqueid> => array('name'   => <name>),
  437.      *                          <uniqueid> => array('name'   => <name>));
  438.      */
  439.     function getLists()
  440.     {
  441.         /* Set up the url and call it. */
  442.         $url sprintf('postdistribution.php?username=%s&password=%s&cmd=GETCOMPACTLIST',
  443.                        urlencode($this->_params['user']),
  444.                        urlencode($this->_params['password']));
  445.         $response $this->_callURL($url);
  446.         if (is_a($response'PEAR_Error')) {
  447.             return $response;
  448.         }
  449.  
  450.         /* Check if there was an error response. */
  451.         if (substr($response022!= 'AQSMS-DISTRIBUTIONLIST'{
  452.             return $this->getError($response_("Could not retrieve distribution lists. %s"));
  453.         }
  454.  
  455.         /* Parse the response and construct the array. */
  456.         list($response$lists_strexplode(','$response2);
  457.  
  458.         /* Check that the full list of distribution lists has been received. */
  459.         $length substr($response22);
  460.         if (strlen($lists_str!= $length{
  461.             return PEAR::raiseError(_("Could not fetch the complete list of distribution lists."));
  462.         }
  463.         $lists_lines explode("\n"$lists_str);
  464.         $lists = array();
  465.         /* Loop through lines and pick out the fields, make sure that the ""
  466.          * are not included in the values, so get the line less 1 char on each
  467.          * end and split for ",". */
  468.         foreach ($lists_lines as $line{
  469.             list($id$name$countexplode('","'substr($line1-1));
  470.             $lists[$id= array('name'  => $name,
  471.                                 'count' => $count);
  472.         }
  473.  
  474.         return $lists;
  475.     }
  476.  
  477.     /**
  478.      * Fetches a specific distribution list from the gateway.
  479.      *
  480.      * @access public
  481.      *
  482.      * @param string  The ID of the distribution list to fetch.
  483.      *
  484.      * @return mixed  An array of numbers in the list on success or PEAR Error
  485.      *                 on failure.
  486.      */
  487.     function getList($id)
  488.     {
  489.         /* Set up the url and call it. */
  490.         $url sprintf('postdistribution.php?username=%s&password=%s&cmd=GETNUMBERSWITHID&distid=%s',
  491.                        urlencode($this->_params['user']),
  492.                        urlencode($this->_params['password']),
  493.                        $id);
  494.         $response $this->_callURL($url);
  495.         if (is_a($response'PEAR_Error')) {
  496.             return $response;
  497.         }
  498.  
  499.         /* Check if there was an error response. */
  500.         if (substr($response022!= 'AQSMS-DISTRIBUTIONLIST'{
  501.             return $this->getError($response_("Could not retrieve distribution list. %s"));
  502.         }
  503.  
  504.         /* Parse the response and construct the array. */
  505.         list($response$list_strexplode(','$response2);
  506.  
  507.         /* Check that the full list of distribution lists has been received. */
  508.         $length substr($response22);
  509.         if (strlen($list_str!= $length{
  510.             return PEAR::raiseError(_("Could not fetch complete distribution list."));
  511.         }
  512.         $list_str trim($list_str);
  513.         list($count$numbersexplode('","'$list_str);
  514.  
  515.         /* TODO: Anything useful that can be done with the count of numbers at
  516.          * the start? */
  517.         $count substr($count1);
  518.  
  519.         /* Explode the list of numbers into an array and return. */
  520.         $numbers substr($numbers0-1);
  521.         return explode(','$numbers);
  522.     }
  523.  
  524.     /**
  525.      * Identifies this gateway driver and returns a brief description.
  526.      *
  527.      * @access public
  528.      *
  529.      * @return array  Array of driver info.
  530.      */
  531.     function getInfo()
  532.     {
  533.         $info['name'_("sms2email via HTTP");
  534.         $info['desc'_("This driver allows sending of messages through the sms2email (http://sms2email.com) gateway, using the HTTP API");
  535.  
  536.         return $info;
  537.     }
  538.  
  539.     /**
  540.      * Returns the required parameters for this gateway driver. The settable
  541.      * parameters for this gateway are:
  542.      *   - user            - The username for authentication on the gateway;
  543.      *   - password        - The password for authentication on the gateway;
  544.      *   - ssl             - Whether or not to use SSL for communication with
  545.      *                       the gateway.
  546.      *   - delivery_report - A URL for a script which would accept delivery
  547.      *                       report from the gateway.
  548.      *
  549.      * @access public
  550.      *
  551.      * @return array  Array of required parameters.
  552.      */
  553.     function getParams()
  554.     {
  555.         $params = array();
  556.         $params['user']     = array('label' => _("Username")'type' => 'text');
  557.         $params['password'= array('label' => _("Password")'type' => 'text');
  558.         $params['ssl']      = array('label'    => _("Use SSL"),
  559.                                     'type'     => 'boolean',
  560.                                     'required' => false);
  561.         $params['delivery_report'= array('label'    => _("URL for your script delivery status report"),
  562.                                            'type'     => 'text',
  563.                                            'required' => false);
  564.                                             
  565.  
  566.         return $params;
  567.     }
  568.  
  569.     /**
  570.      * Returns the parameters that can be set as default for sending messages
  571.      * using this gateway driver and displayed when sending messages.
  572.      *
  573.      * @access public
  574.      *
  575.      * @return array  Array of parameters that can be set as default.
  576.      */
  577.     function getDefaultSendParams()
  578.     {
  579.         $params = array();
  580.         $params['from'= array(
  581.             'label' => _("Source address"),
  582.             'type' => 'text');
  583.  
  584.         $params['deliv_time'= array(
  585.             'label' => _("Delivery time"),
  586.             'type' => 'enum',
  587.             'params' => array(array('now' => _("immediate")'user' => _("user select"))));
  588.  
  589.         $types = array('SMS_TEXT' => 'SMS_TEXT''SMS_FLASH' => 'SMS_FLASH');
  590.         $params['msg_type'= array(
  591.             'label' => _("Message type"),
  592.             'type' => 'multienum',
  593.             'params' => array($types));
  594.  
  595.         return $params;
  596.     }
  597.  
  598.     /**
  599.      * Returns the parameters for sending messages using this gateway driver,
  600.      * displayed when sending messages. These are filtered out using the
  601.      * default values set up when creating the gateway.
  602.      *
  603.      * @access public
  604.      *
  605.      * @return array  Array of required parameters.
  606.      * @todo  Would be nice to use a time/date setup rather than minutes from
  607.      *         now for the delivery time. Upload field for ringtones/logos?
  608.      */
  609.     function getSendParams($params)
  610.     {
  611.         if (empty($params['from'])) {
  612.             $params['from'= array(
  613.                 'label' => _("Source address"),
  614.                 'type' => 'text');
  615.         }
  616.  
  617.         if ($params['deliv_time'== 'user'{
  618.             $params['deliv_time'= array(
  619.                 'label' => _("Delivery time"),
  620.                 'type' => 'int',
  621.                 'desc' => _("Value in minutes from now."));
  622.         }
  623.  
  624.         if (count($params['msg_type']> 1{
  625.             $params['msg_type'= array(
  626.                 'label' => _("Message type"),
  627.                 'type' => 'enum',
  628.                 'params' => array($params['msg_type']));
  629.         else {
  630.             $params['msg_type'$params['msg_type'][0];
  631.         }
  632.  
  633.         return $params;
  634.     }
  635.  
  636.     /**
  637.      * Returns a string representation of an error code.
  638.      *
  639.      * @access public
  640.      *
  641.      * @param int $error             The error code to look up.
  642.      * @param optional string $text  An existing error text to use to raise a
  643.      *                                PEAR Error.
  644.      *
  645.      * @return mixed  A textual message corrisponding to the error code or a
  646.      *                 PEAR Error if passed an existing error text.
  647.      *
  648.      * @todo  Check which of these are actually required and trim down the list.
  649.      */
  650.     function getError($error$error_text '')
  651.     {
  652.         $error trim($error);
  653.  
  654.         /* An array of error codes returned by the gateway. */
  655.         $errors = array(
  656.             'AQSMS-NOAUTHDETAILS'        => _("No username and/or password sent."),
  657.             'AQSMS-AUTHERROR'            => _("Incorrect username and/or password."),
  658.             'AQSMS-NOMSG'                => _("No message supplied."),
  659.             'AQSMS-NODEST'               => _("No destination supplied."),
  660.             'AQSMS-NOCREDIT'             => _("Insufficient credit."),
  661.             'AQSMS-NONAMESUPPLIED'       => _("No name specified."),
  662.             'AQSMS-NONUMBERSUPPLIED'     => _("No number specified."),
  663.             'AQSMS-ADDRESSBOOKERROR'     => _("There was an error performing the specified address book function. Please try again later."),
  664.             'AQSMS-CONTACTIDERROR'       => _("The contact ID number was not specified, left blank or was not found in the database."),
  665.             'AQSMS-CONTACTUPDATEERROR'   => _("There was an error updating the contact details. Please try again later."),
  666.             'AQSMS-DISTIDERROR'          => _("The distribution list ID was either not specified, left blank or not found in the database."),
  667.             'AQSMS-NODISTLISTSUPPLIED'   => _("The distribution list was not specified."),
  668.             'AQSMS-INSUFFICIENTCREDITS'  => _("Insufficient credit to send to the distribution list."),
  669.             'AQSMS-NONUMBERLISTSUPPLIED' => _("Numbers not specified for updating in distribution list."),
  670.             'AQSMS-DISTLISTUPDATEERROR'  => _("There was an error updating the distribution list. Please try again later."));
  671.  
  672.         if (empty($error_text)) {
  673.             return $errors[$error];
  674.         else {
  675.             return PEAR::raiseError(sprintf($error_text$errors[$error]));
  676.         }
  677.     }
  678.  
  679.     /**
  680.      * Do the http call using a url passed to the function.
  681.      *
  682.      * @access private
  683.      *
  684.      * @param string $url  The url to call.
  685.      *
  686.      * @return mixed  The response on success or PEAR Error on failure.
  687.      */
  688.     function _callURL($url)
  689.     {
  690.         $options['method''POST';
  691.         $options['timeout'= 5;
  692.         $options['allowRedirects'= true;
  693.  
  694.         $url ($this->_params['ssl''https://' 'http://'$this->_base_url $url;
  695.  
  696.         if (!@include_once 'HTTP/Request.php'{
  697.             return PEAR::raiseError(_("Missing PEAR package HTTP_Request."));
  698.         }
  699.         $http &new HTTP_Request($url$options);
  700.         @$http->sendRequest();
  701.         if ($http->getResponseCode(!= 200{
  702.             return PEAR::raiseError(sprintf(_("Could not open %s.")$url));
  703.         }
  704.  
  705.         return $http->getResponseBody();
  706.     }
  707.  
  708. }

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