/** * Initializes any environment settings. * * @return void */ function envinit() { if (defined('PROXY_HOST') && defined('PROXY_PORT')) { // set any RESTFul environmental settings RestfulEnvironment::setProxy($proxy_host, $proxy_port); } if (defined('ACCEPT_ALL_CERTS')) { RestfulEnvironment::setAcceptAllCerts($acceptAllCerts); } }
public function testRequest() { require __DIR__ . '/cfgs/ads_config.php'; if (isset($proxyHost) && isset($proxyPort)) { RestfulEnvironment::setProxy($proxyHost, $proxyPort); } if (isset($allowAllCerts)) { RestfulEnvironment::setAcceptAllCerts($allowAllCerts); } $osrvc = new OAuthTokenService($FQDN, $api_key, $secret_key); $token = $osrvc->getToken('ADS'); $adsService = new ADSService($FQDN, $token); $category = Category::AUTO; $ua = 'Mozilla/5.0 (Android; Mobile; rv:13.0) Gecko/13.0 Firefox/13.0'; $udid = '938382893239492349234923493249'; $response = $adsService->getAdvertisement($category, $ua, $udid); $this->assertTrue($response->getContent() != null); }
public function testRequest() { require __DIR__ . '/cfgs/sms_config.php'; if (isset($proxyHost) && isset($proxyPort)) { RestfulEnvironment::setProxy($proxyHost, $proxyPort); } if (isset($allowAllCerts)) { RestfulEnvironment::setAcceptAllCerts($allowAllCerts); } $osrvc = new OAuthTokenService($FQDN, $api_key, $secret_key); $token = $osrvc->getToken('SMS'); $srvc = new SMSService($FQDN, $token); $response = $srvc->getMessages($getMsgsShortCode); $this->assertTrue($response->getResourceUrl() != null); $response = $srvc->sendSMS($phoneNumber, 'test msg ok', false); $this->assertTrue($response->getMessageId() != null); $msgId = $response->getMessageId(); $response = $srvc->getSMSDeliveryStatus($msgId); $this->assertTrue($response->getResourceUrl() != null); }
public function testRequest() { require __DIR__ . '/cfgs/speech_config.php'; if (isset($proxyHost) && isset($proxyPort)) { RestfulEnvironment::setProxy($proxyHost, $proxyPort); } if (isset($allowAllCerts)) { RestfulEnvironment::setAcceptAllCerts($allowAllCerts); } $osrvc = new OAuthTokenService($FQDN, $api_key, $secret_key); $token = $osrvc->getToken('Speech,TTS,STTC'); $srvc = new SpeechService($FQDN, $token); $fname = __DIR__ . '/files/BostonCeltics.wav'; $response = $srvc->speechToText($fname, 'Generic'); $this->assertTrue($response != null); $response = $srvc->textToSpeech('text/plain', 'testing ok'); $this->assertTrue($response != null); $response = $srvc->speechToTextCustom('GenericHints', $fname); $this->assertTrue($response != null); }
/** * Initializes any environment settings. * * @return void */ function envinit() { require __DIR__ . '/../config.php'; // maintain backwards compability with older configs if (isset($proxy_host)) { $proxyHost = $proxy_host; } if (isset($proxy_port)) { $proxyPort = $proxy_port; } if (isset($accept_all_certs)) { $acceptAllCerts = $accept_all_certs; } // set any RESTFul environmental settings if (isset($proxyHost) && isset($proxyPort)) { RestfulEnvironment::setProxy($proxy_host, $proxy_port); } if (isset($acceptAllCerts)) { RestfulEnvironment::setAcceptAllCerts($acceptAllCerts); } }
<?php require_once __DIR__ . '/codekit.lib/Restful/RestfulEnvironment.php'; // To initialize Restful environment to accept certs require_once __DIR__ . '/service_provider/Debug.php'; // To enable debugging from other files # # Note: This SDK disables SSL Certificate verification by default for ease if development. # # If your application requires high level of security, you may enable this feature by reading # the related notes for your PHP installation. # define("ENABLE_SSL_CHECK", false); use Att\Api\Restful\RestfulEnvironment; RestfulEnvironment::setAcceptAllCerts(true); session_start(); # # Turn on/off debugging and define the location of the PHP debug file. # define("DEBUG", "0"); define("DEBUG_LOGGER", __DIR__ . "/att-php.txt"); $config = array("AppKey" => 'abcdefgh123456', "Secret" => 'abcdefgh123456', "localServer" => "http://localhost:4567", "apiHost" => 'https://api.att.com', "clientModelScope" => "", "defaultGrammarFile" => "grammar.srgs", "defaultDictionaryFile" => "dictionary.pls", "ReduceTokenExpiryInSeconds_Debug" => "0"); ini_set("memory_limit", "12M"); // For 4.3.0 <= PHP <= 5.4.0 if (!function_exists('http_response_code')) { function http_response_code($newcode = NULL) { static $code = 200; if ($newcode !== NULL) { header('X-PHP-Response-Code: ' . $newcode, true, $newcode); if (!headers_sent()) {
private function _setInternalOptions($url) { if ($this->_chunked) { $this->setHeader('Content-Transfer-Encoding', 'chunked'); } // get result as a string instead of printing it out $this->_options[CURLOPT_RETURNTRANSFER] = true; // return headers as part of response $this->_options[CURLOPT_HEADER] = true; // set the URL $this->_options[CURLOPT_URL] = $url; // set any proxy settings, if applicable if (RestfulEnvironment::getProxyHost() != null) { $host = RestfulEnvironment::getProxyHost(); $port = RestfulEnvironment::getProxyPort(); $this->_options[CURLOPT_PROXY] = $host; $this->_options[CURLOPT_PROXYPORT] = $port; } if (RestfulEnvironment::getAcceptAllCerts()) { // TODO: set if true or false, not just on true $shouldAccept = RestfulEnvironment::getAcceptAllCerts(); $this->_options[CURLOPT_SSL_VERIFYHOST] = !$shouldAccept; $this->_options[CURLOPT_SSL_VERIFYPEER] = !$shouldAccept; } // Add HTTP headers to CURL $headers = array(); foreach ($this->_headers as $name => $value) { $headers[] = $name . ': ' . $value; } $this->_options[CURLOPT_HTTPHEADER] = $headers; }
/** * Initializes common information for a Controller object. */ protected function __construct() { // Copy config values to member variables include __DIR__ . '/../../config.php'; $this->oauthFQDN = isset($oauthFQDN) ? $oauthFQDN : $FQDN; $this->apiFQDN = isset($apiFQDN) ? $apiFQDN : $FQDN; $this->clientId = $api_key; $this->clientSecret = $secret_key; $this->scope = $scope; $this->results = array(); $this->errors = array(); // set any RESTFul environmental settings if (isset($proxy_host) && isset($proxy_port)) { RestfulEnvironment::setProxy($proxy_host, $proxy_port); } if (isset($accept_all_certs)) { RestfulEnvironment::setAcceptAllCerts($accept_all_certs); } }
<?php session_start(); include __DIR__ . '/../config.php'; require_once __DIR__ . '/../lib/WebRTC/WebRTCService.php'; require_once __DIR__ . '/../lib/Restful/RestfulEnvironment.php'; use Att\Api\WebRTC\WebRTCService; use Att\Api\Restful\RestfulEnvironment; use Exception; if (isset($proxy_host) && isset($proxy_port)) { RestfulEnvironment::setProxy($proxy_host, $proxy_port); } if (isset($accept_all_certs)) { RestfulEnvironment::setAcceptAllCerts($accept_all_certs); } try { $user = $_POST['user']; $token = unserialize($_SESSION['token']); $webrtcSrvc = new WebRTCService($FQDN, $token); $webrtcSrvc->associateToken($user); if (function_exists('http_response_code')) { http_response_code(500); } else { header("HTTP/1.1 201 Created"); } } catch (Exception $e) { if (function_exists('http_response_code')) { http_response_code(500); } else { header("HTTP/1.1 500 Internal Server Error"); }