コード例 #1
0
 /**
  * Constructor.
  *
  * @param string               $sid      Account SID
  * @param string               $token    Account auth token
  * @param string               $version  API version
  * @param Services_Twilio_Http $_http    A HTTP client
  * @param int                  $retryAttempts Number of times to retry failed requests
  */
 public function __construct($sid, $token, $version = null, Services_Twilio_TinyHttp $_http = null, $retryAttempts = 1)
 {
     $this->version = in_array($version, $this->versions) ? $version : end($this->versions);
     if (null === $_http) {
         if (in_array('curl', get_loaded_extensions())) {
             $_http = new Services_Twilio_TinyHttp("https://api.twilio.com", array("curlopts" => array(CURLOPT_USERAGENT => self::USER_AGENT, CURLOPT_HTTPHEADER => array('Accept-Charset: utf-8'), CURLOPT_CAINFO => dirname(__FILE__) . '/cacert.pem')));
         } else {
             $_http = new Services_Twilio_HttpStream("https://api.twilio.com", array("http_options" => array("http" => array("user_agent" => self::USER_AGENT, "header" => "Accept-Charset: utf-8\r\n"), "ssl" => array('verify_peer' => true, 'cafile' => dirname(__FILE__) . '/cacert.pem', 'verify_depth' => 5))));
         }
     }
     $_http->authenticate($sid, $token);
     $this->http = $_http;
     $this->accounts = new Services_Twilio_Rest_Accounts($this, "/{$this->version}/Accounts");
     $this->account = $this->accounts->get($sid);
     $this->retryAttempts = $retryAttempts;
 }
コード例 #2
0
 public function __construct($sid, $token, $version = null, Services_Twilio_TinyHttp $_http = null, $retryAttempts = 1)
 {
     $this->version = in_array($version, $this->versions) ? $version : end($this->versions);
     if (null === $_http) {
         if (!in_array('openssl', get_loaded_extensions())) {
             throw new Services_Twilio_HttpException("The OpenSSL extension is required but not currently enabled. For more information, see http://php.net/manual/en/book.openssl.php");
         }
         if (in_array('curl', get_loaded_extensions())) {
             $_http = new Services_Twilio_TinyHttp($this->_getBaseUri(), array("curlopts" => array(CURLOPT_USERAGENT => self::qualifiedUserAgent(phpversion()), CURLOPT_HTTPHEADER => array('Accept-Charset: utf-8'))));
         } else {
             $_http = new Services_Twilio_HttpStream($this->_getBaseUri(), array("http_options" => array("http" => array("user_agent" => self::qualifiedUserAgent(phpversion()), "header" => "Accept-Charset: utf-8\r\n"), "ssl" => array('verify_peer' => true, 'verify_depth' => 5))));
         }
     }
     $_http->authenticate($sid, $token);
     $this->http = $_http;
     $this->retryAttempts = $retryAttempts;
 }