public function testRequest() { require __DIR__ . '/cfgs/ads_config.php'; if (isset($proxyHost) && isset($proxyPort)) { RestfulEnvironment::setProxy($proxyHost, $proxyPort); } if (isset($allowAllCerts)) { RestfulEnvironment::setAcceptAllCerts($allowAllCerts); } $tokenSrvc = new OAuthTokenService($FQDN, $api_key, $secret_key); $token = $tokenSrvc->getToken('ADS'); $this->assertTrue($token->getAccessToken() != ''); $token = $tokenSrvc->refreshToken($token); $this->assertTrue($token->getAccessToken() != ''); }
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); }
use Att\Api\ADS\Category; use Att\Api\OAuth\OAuthTokenService; use Att\Api\Srvc\ServiceException; // Use the app account settings from developer.att.com for the following values. // Make sure that the API scope is set to ADS for the Advertising API before // retrieving the App Key and App Secret. // Enter the value from the 'App Key' field obtained at developer.att.com // in your app account. $clientId = 'ENTER VALUE!'; // Enter the value from the 'App Secret' field obtained at developer.att.com // in your app account. $clientSecret = 'ENTER VALUE!'; // Create the service for requesting an OAuth access token. $osrvc = new OAuthTokenService('https://api.att.com', $clientId, $clientSecret); // Get the OAuth access token using the ADS API scope. $token = $osrvc->getToken('ADS'); // Create the service for interacting with the Advertising API. $adsSrvc = new ADSService('https://api.att.com', $token); try { // Specify the user agent (must be mobile). $ua = 'Mozilla/5.0 (Android; Mobile; rv:13.0) Gecko/13.0 Firefox/13.0'; // Specify a unique id. $udid = '938382893239492349234923493249'; // Send the request to the API Gateway for getting an advertisement // using 'auto' as the category. $cat = Category::AUTO; $response = $adsSrvc->getAdvertisement($cat, $ua, $udid); echo 'clickUrl: ' . $response->getClickUrl() . "\n"; echo 'adType: ' . $response->getAdsType() . "\n"; } catch (ServiceException $se) { echo $se->getErrorResponse();
/** * Retrieves a client token from AT&T * * @method getClientCredentials * * @return {Response} Returns Response object */ public function getClientCredentials() { // Create service for requesting an OAuth token $osrvc = new OAuthTokenService($this->base_url, $this->client_id, $this->client_secret); // Get OAuth token $token = $osrvc->getToken($this->clientModelScope); $_SESSION['client_token'] = $token->getAccessToken(); $_SESSION['client_expires_at'] = (int) $token->getTokenExpiry(); $_SESSION['client_refresh_token'] = $token->getRefreshToken(); return $token; }
// Use any namespaced classes. use Att\Api\OAuth\OAuthTokenService; use Att\Api\Speech\SpeechService; // Use the app account settings from developer.att.com for the following values. // Make sure that the API scope is set to SPEECH for the Speech API before // retrieving the App Key and App Secret. // Enter the value from the 'App Key' field obtained at developer.att.com // in your app account. $clientId = 'ENTER VALUE!'; // Enter the value from the 'App Secret' field obtained at developer.att.com // in your app account. $clientSecret = 'ENTER VALUE!'; // Create the service for requesting an OAuth access token. $osrvc = new OAuthTokenService('https://api.att.com', $clientId, $clientSecret); // Get the OAuth access token. $token = $osrvc->getToken('SPEECH,STTC,TTS'); // Create the service for interacting with the Speech API. $speechSrvc = new SpeechService('https://api.att.com', $token); // The Speech API requires the audio files to be certain formats. In order to // convert speech files to the proper format, the ffmpeg program may be used. // The ffmpeg program can be downloaded from https://ffmpeg.org/ // The following try/catch blocks can be used to test the methods of the // Speech API. To test a specific method, comment out the other try/catch blocks. /* This try/catch block tests the speechToText method. */ try { // Enter the path of the file to translate. For example: $fname = '/tmp/file.wav'; $fname = 'ENTER VALUE!'; $speechContext = 'Generic'; // Send the request to convert the speech file to text. $response = $speechSrvc->speechToText($fname, $speechContext); echo 'responseId: ' . $response->getResponseId() . "\n";
// Use any namespaced classes. use Att\Api\OAuth\OAuthTokenService; use Att\Api\SMS\SMSService; // Use the app account settings from developer.att.com for the following values. // Make sure that the API scope is set to SMS for the SMS API before // retrieving the App Key and App Secret. // Enter the value from the 'App Key' field obtained at developer.att.com // in your app account. $clientId = 'ENTER VALUE!'; // Enter the value from the 'App Secret' field obtained at developer.att.com // in your app account. $clientSecret = 'ENTER VALUE!'; // Create the service for requesting an OAuth access token. $osrvc = new OAuthTokenService('https://api.att.com', $clientId, $clientSecret); // Get the OAuth access token using the SMS scope. $token = $osrvc->getToken('SMS'); // Create the service for interacting with the SMS API. $smsSrvc = new SMSService('https://api.att.com', $token); /* This try/catch block tests the sendSMS method. */ try { // Specify the phone number where the SMS message is sent. // For example: $number = '5555555555'; $number = 'ENTER VALUE!'; // Send the SMS message to the specified phone number and // do not receive status notification. $response = $smsSrvc->sendSMS($number, 'Test Message', false); echo 'msgId: ' . $response->getMessageId() . "\n"; } catch (ServiceException $se) { echo $se->getErrorResponse(); } /* This try/catch block tests the getSMSDeliveryStatus method. */
$scopes = 'ENTER_SCOPE_ONE,ENTER_SCOPE_TWO'; // Enter the value from the 'App Key' field obtained at developer.att.com // in your app account. $clientId = 'ENTER VALUE!'; // Enter the value from the 'App Secret' field obtained at developer.att.com // in your app account. $clientSecret = 'ENTER VALUE!'; // The OAuth access token can be obtained in the following ways. // Client Credentials - Does not require user authentication to use the API. // Authorization Code - Requires user authentication to use the API. // Create the service for requesting an OAuth access token. $osrvc = new OAuthTokenService('https://api.att.com', $clientId, $clientSecret); /* This try/catrch block shows the Client Credentials flow. */ try { // Get the OAuth access token using the previously specified scopes. $token = $osrvc->getToken($scopes); echo 'Client Credentials access token: ' . $token->getAccessToken() . "\n"; } catch (OAuthException $se) { echo $se->getErrorDescription(); } /* This try/catch block shows the Authorization Code flow. */ try { // Get the OAuth code by opening a browser to the following URL: // https://api.att.com/oauth/v4/authorize?client_id=CLIENT_ID&scope=SCOPE&redirect_uri=REDIRECT_URI // replacing CLIENT_ID, SCOPE, and REDIRECT_URI with the values configured at // developer.att.com. // After authenticating, copy the OAuth code from the browser URL. $oauthCode = "ENTER VALUE!"; // Get the OAuth access token using the OAuth code. $token = $osrvc->getTokenUsingCode(new OAuthCode($oauthCode)); echo 'Authorization Code access token: ' . $token->getAccessToken() . "\n";
use Att\Api\Notary\NotaryService; use Att\Api\OAuth\OAuthTokenService; use Att\Api\Payment\PaymentService; // Use the app account settings from developer.att.com for the following values. // Make sure that the API scope is set to Payment for the Payment API before // retrieving the App Key and App Secret. // Enter the value from the 'App Key' field obtained at developer.att.com // in your app account. $clientId = 'ENTER VALUE!'; // Enter the value from the 'App Secret' field obtained at developer.att.com // in your app account. $clientSecret = 'ENTER VALUE!'; // Create the service for requesting an OAuth access token. $osrvc = new OAuthTokenService('https://api.att.com', $clientId, $clientSecret); // Get the OAuth access token using the Payment scope. $token = $osrvc->getToken('Payment'); // Create the service for interacting with the Notary API $notarySrvc = new NotaryService('https://api.att.com', $clientId, $clientSecret); // Create the service for interacting with the Payment API $paymentSrvc = new PaymentService('https://api.att.com', $token); // The following try/catch blocks can be used to test the methods of the // Payment API. To test a specific method, comment out the other try/catch blocks. /* This try/catch block tests the getNotary method. */ try { // Specify the payload. $payload = 'ENTER VALUE!'; // Send the request for getting the notary. $response = $notarySrvc->getNotary($payload); echo 'signature: ' . $response->getSignature() . "\n"; } catch (ServiceException $se) { echo $se->getErrorResponse();