/// <summary> /// Use the app account settings from developer.att.com for the following values. /// Make sure DC is enabled for the app key/secret /// </summary> protected void Page_Load(object sender, EventArgs e) { // Enter the value from the 'App Key' field obtained at developer.att.com in your // app account. string clientId = ""; // Enter the value from the 'App Secret' field obtained at developer.att.com // in your app account. string secretKey = ""; // Set the fully-qualified domain name to: https://api.att.com string fqdn = "https://api.att.com"; // Set the redirect URI for returning after consent flow. string authorizeRedirectUri = "http://localhost/DC.aspx"; // Set the scope to DC string scope = "DC"; // Create the service for requesting an OAuth access token. oauth = new OAuth(fqdn, clientId, secretKey, authorizeRedirectUri, scope); // If there's no access token yet go through the concent flow. if (Request["code"] == null) { // Authenticate the user. Note: This requires a Web browser. // Obtain the url string that is used for consent flow. if (!oauth.GetAuthCode()) { // Get any error codes returned by the API Gateway. string authCodeError = oauth.getAuthCodeError; } } else { //Get code in the query parameters after doing consent flow. this.oauth.authCode = Request["code"].ToString(); // Get the OAuth access token using the OAuth authentication code. if (oauth.GetAccessToken(OAuth.AccessTokenType.AuthorizationCode)) { // Get access token OAuthToken at = new OAuthToken(); accessToken = at.getAccessToken(oauth.accessTokenJson); // Create the service for making the method request. devices = new Devices(fqdn, accessToken); try { // Make an Make a method call to the Device Capabilities API. DeviceIdObj.RootObject dc = devices.GetDeviceCapabilities(); } catch (Exception respex) { string error = respex.StackTrace; } } } }
/// <summary> /// Use the app account settings from developer.att.com for the following values. /// Make sure ADS is enabled for the App Key and the App Secret. /// </summary> protected void Page_Load(object sender, EventArgs e) { // Enter the value from the 'App Key' field obtained at developer.att.com in your // app account. string appKey = ""; // Enter the value from the 'App Secret' field obtained at developer.att.com // in your app account. string appSecret = ""; // Set the fully-qualified domain name to: https://api.att.com string fqdn = "https://api.att.com"; //Set the scope to ADS string scope = "ADS"; // Create the service for requesting an OAuth access token. var oauth = new OAuth(fqdn, appKey, appSecret, scope); // Get the OAuth access token using the Client Credentials. if (oauth.GetAccessToken(OAuth.AccessTokenType.ClientCredentials)) { // Get access token OAuthToken at = new OAuthToken(); var accessToken = at.getAccessToken(oauth.accessTokenJson); // Create the service for making the method request. var ads = new Ads(fqdn, accessToken); // Set params: string category = "Auto"; string udid = "123456789012345678901234567890"; string userAgent = "Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19"; try { // Make an Make a method call to the Advertising API. // param 1 category // param 2 udid // param 3 user agent AdsObj.RootObject ads_obj = ads.GetAds(category, udid, userAgent); } catch (Exception ex) { string error = ex.StackTrace; } } }
/// <summary> /// Use the app account settings from developer.att.com for the following values. /// Make sure that the API scope is set to AAB for the Address Book API /// before retrieving the App Key and App Secret. /// </summary> protected void Page_Load(object sender, EventArgs e) { // Enter the value from the 'App Key' field obtained at developer.att.com in your // app account. string clientId = ""; // Enter the value from 'App Secret' field obtained at developer.att.com // in your app account. string secretKey = ""; // Set the fully-qualified domain name to: https://api.att.com string fqdn = "https://api.att.com"; // Set the redirect URI for returning after consent flow. string authorizeRedirectUri = ""; //Set the scope to AAB string scope = "AAB"; // Create the service for requesting an OAuth access token. var oauth = new OAuth(fqdn, clientId, secretKey, authorizeRedirectUri, scope); // If there's no access token yet go through the consent flow. if (Request["code"] == null) //if(false) { // Authenticate the user. Note: This requires a Web browser. // Obtain the url string that is used for consent flow. if (!oauth.GetAuthCode()) { //Get any error codes returned by the API Gateway. string authCodeError = oauth.getAuthCodeError; } } else { //Get code in the query parameters after doing consent flow. oauth.authCode = Request["code"].ToString(); //Get the OAuth access token using the OAuth authentication code. if (oauth.GetAccessToken(OAuth.AccessTokenType.AuthorizationCode)) { // Get access token // Method takes: // param 1: string access token json object OAuthToken at = new OAuthToken(); var accessToken = at.getAccessToken(oauth.accessTokenJson); // Create the service for making the method request. var addressbook = new AddressBook(fqdn, accessToken); //************************************************************************* // Operation: Create Contact // Create a new contact for our Address Book // Convert contact object to JSON string. var createContactObj = new ContactObj.RootObject() { contact = new ContactObj.Contact() { firstName = "<Firstname>", lastName = "<lastname>", organization = "<organization>" } }; var contactJson = JsonConvert.SerializeObject(createContactObj, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); try { // Make a method call to the Address Book API. // Method takes: // param 1: string contact json string contactId = addressbook.createContact(contactJson); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Get Contact // Get an existing contact from Address Book. try { // Make a method call to the Address Book API. // Method takes: // param 1: string contact id QuickContactObj.RootObject getContactResponseData = addressbook.getContact("<enter contactId>"); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* //Operation: Get Contacts // Search for existing contacts from Address Book // Search for the created contact: string searchField = "<Enter search word>"; try { // Make a method call to the Address Book API. // Method takes: // param 1: string searchField QuickContactObj.RootObject getContactsResponseData = addressbook.getContacts(searchField); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Get Contact Groups // Retrieving the list of groups a contact is belonging to. try { // Make a method call to the Address Book API. // Method takes: // param 1: string contact id string getContactGroupsResponseData = addressbook.getContactGroups("<enter contactId>"); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Update Contact // Updates a contact based on the provided contact data structure. // Enter contact id to update var updateContactId = "<Enter contactId>"; //Convert contact object to JSON var updateContactObj = new ContactObj.RootObject() { contact = new ContactObj.Contact() { firstName = "testFirst", lastName = "testLast", organization = "att", } }; var updateContactJson = JsonConvert.SerializeObject(updateContactObj, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); try { // Make a method call to the Address Book API. // Method takes: // param 1: string contact id // param 2: string contact json addressbook.updateContact(updateContactId, updateContactJson); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Create Group // The Create Group method enables creating a USER group // Convert group object to JSON var createGroupObj = new GroupObj.RootObject() { group = new GroupObj.Group() { groupName = "gGroup", groupType = "gtype" } }; string groupId = String.Empty; var createGroupJson = JsonConvert.SerializeObject(createGroupObj, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); try { // Make a method call to the Address Book API. // Method takes: // param 1: string contact id groupId = addressbook.createGroup(createGroupJson); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Get Groups // The Get Groups method enables retrieving the list of the subscriber’s groups with rules for ordering and pagination. // Get group by group id string groupsName = "gGroup"; try { // Make a method call to the Address Book API. // Method takes: // param 1: string groups_name GroupObj.RootObject groups = addressbook.getGroups(groupsName); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Update Groups // The Update Group method enables updating an existing USER group //Convert group object to JSON var updateGroupObj = new GroupObj.RootObject() { group = new GroupObj.Group() { groupName = "newName", groupType = "newType" } }; var updateGroupJson = JsonConvert.SerializeObject(updateGroupObj, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); try { // Make a method call to the Address Book API. // Method takes: // param 1: string group id // param 2: string group json addressbook.updateGroup(groupId, updateGroupJson); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Add Contact(s) to a Group string cGContactId = "<Enter contactId>"; string cGGroupId = "<Enter groupId>"; try { // Make a method call to the Address Book API. // Method takes: // param 1: string contact id // param 2: string group id addressbook.addContactToGroup(cGGroupId, cGContactId); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Remove Contact(s) from a Group string rcGContactId = "<Enter contactId>"; string rcGGroupId = "<Enter groupId>"; try { // Make a method call to the Address Book API. // Method takes: // param 1: string contact id // param 2: string group id addressbook.removeContactsFromGroup(rcGGroupId, rcGContactId); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Get Group Contacts // The Get Groups Contact method enables retrieving the list of contacts owned by a group string ggcGroupId = "<Enter groupId>"; try { // Make a method call to the Address Book API. // Method takes: // param 1: string contact id // param 2: string group id string responseGetFGroupContact = addressbook.getGroupContacts(ggcGroupId); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Delete Groups // The Delete Group method enables deleting a group. string delGroupId = "<Enter groupId>"; try { // Make a method call to the Address Book API. // Method takes: // param 1: string group id addressbook.deleteGroup(delGroupId); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Get MyInfo // Get the subscriber’s personal contact card. try { // Make AddressBook API call // Method takes: 0 param addressbook.getMyInfo(); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Delete Contact // Delete a contact based on the provided contact id. // Enter contact id to update var deleteContactId = "<Enter contactId>";//"<Enter contact id>"; try { // Make a method call to the Address Book API. // Method takes: // param 1: string contact id addressbook.deleteContact(deleteContactId); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Update MyInfo // Update the subscriber’s personal contact card. //Convert MyInfo object to JSON var updateMyinfoObj = new ContactObj.RootObject() { myInfo = new ContactObj.Contact() { firstName = "michelle", lastName = "pai", organization = "att" } }; var updateMyinfoJson = JsonConvert.SerializeObject(updateMyinfoObj, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); try { // Make a method call to the Address Book API. // Method takes: // param 1: string myinfo json addressbook.updateMyInfo(updateMyinfoJson); } catch (Exception ex) { string error = ex.Message; } } } }
protected void Page_Load(object sender, EventArgs e) { // Enter the value from the 'App Key' field obtained at developer.att.com in your // app account. string clientId = ""; // Enter the value from the 'App Secret' field obtained at developer.att.com // in your app account. string secretKey = ""; // Set the fully-qualified domain name to: https://api.att.com string fqdn = "https://api.att.com"; //Set the scope to AAB string scope = "SMS"; //Create the service for requesting an OAuth access token. var oauth = new OAuth(fqdn, clientId, secretKey, scope); //Get the OAuth access token using the Client Credentials. if (oauth.GetAccessToken(OAuth.AccessTokenType.ClientCredentials)) { // Get access token OAuthToken at = new OAuthToken(); string accessToken = at.getAccessToken(oauth.accessTokenJson); // Create the service for making the method request. var sms = new SMS(fqdn, accessToken); //************************************************************************* // Operation: Send SMS // Set params: string address = "tel:+10000000000"; string message = "<Enter message>"; string messageId = String.Empty; try { // Make an Make a method call to the SMS API. // Method takes: // param 1: address // param 1: message OutboundSMSResponseObj.RootObject sendSMSresponseObj = sms.sendSMS(address, message); messageId = sendSMSresponseObj.outboundSMSResponse.messageId; } catch (Exception respex) { string error = respex.StackTrace; } //************************************************************************* // Operation: Get SMS string RegistrationID = "00000000"; try { // Make an Make a method call to the SMS API. // Method takes: // param 1: RegistrationID InboundSmsMessageObj.RootObject getSMSresponseObj = sms.getSMS(RegistrationID); } catch (Exception respex) { string error = respex.StackTrace; } //************************************************************************* // Operation: Get SMS Delivery Status try { // Make an Make a method call to the SMS API. // Method takes: // param 1: messageID DeliveryInfoObj.RootObject deliveryStatusResponse = sms.getSMSDeliveryStatus(messageId); } catch (Exception respex) { string error = respex.StackTrace; } } }
protected void Page_Load(object sender, EventArgs e) { // Enter the value from the 'App Key' field obtained at developer.att.com in your // app account. string clientId = ""; // Enter the value from the 'App Secret' field obtained at developer.att.com // in your app account. string secretKey = ""; // Set the fully-qualified domain name to: https://api.att.com string fqdn = "https://api.att.com"; //Set the scope to Payment string scope = "Payment"; // Create the service for requesting an OAuth access token. var oauth = new OAuth(fqdn, clientId, secretKey, scope); // Get the OAuth access token using Client Credential method. if (oauth.GetAccessToken(OAuth.AccessTokenType.ClientCredentials)) { // Get access token OAuthToken at = new OAuthToken(); string accessToken = at.getAccessToken(oauth.accessTokenJson); // Create the service for making the method request. var payment = new Payment(fqdn, accessToken); if (string.IsNullOrEmpty((string)Session["NewSubscription"])) { /// <summary> /// Create new subscription /// </summary> /// <param name="apiKey">apiKey</param> /// <param name="secretKey">secretKey</param> /// <param name="amount">amount</param> /// <param name="category">category</param> /// <param name="channel">channel</param> /// <param name="description">description</param> /// <param name="merchantTransactionId">merchantTransactionId</param> /// <param name="merchantProductId">merchantProductId</param> /// <param name="merchantRedirectURI">merchantRedirectURI</param> /// <param name="merchantSubscriptionId">merchantSubscriptionId</param> /// <param name="isPurchaseOnNoActiveSubscription">isPurchaseOnNoActiveSubscription</param> /// <param name="subscriptionRecurringNumber">subscriptionRecurringNumber</param> /// <param name="subscriptionRecurringPeriod">subscriptionRecurringPeriod</param> /// <param name="subscriptionRecurringPeriodAmount">subscriptionRecurringPeriodAmount</param> string redirectUrl = payment.createNewSubscriptionRedirectUrl( clientId, secretKey, 0.01, 3, "MOBILE_WEB", "description", merchantTransactionId, "merchantProductId000111", "http://localhost/PaymentNewSubscription.aspx", merchantSubscriptionId, false, 99999, "MONTHLY", 1); Session["NewSubscription"] = "created"; //Response.Redirect(redirectUrl); } if ((Request["success"] != null) && Request.QueryString["success"].ToString() == "false") { errorCreateNew = new Dictionary <string, string>(); foreach (String key in Request.QueryString.AllKeys) { errorCreateNew.Add(key, Request.QueryString[key]); } throw new Exception(Request.QueryString["faultDescription"]); } if ((Request["SubscriptionAuthCode"] != null)) { SubscriptionAuthCode = Request.QueryString["SubscriptionAuthCode"].ToString(); } /// <summary> /// Call getSubscriptionStatus operation return getSubscriptionStatus object /// </summary> /// <param name="idType">idType</param> /// <param name="id">id</param> SubscriptionStatusResponseObj.RootObject getSubscriptionStatus = payment.getSubscriptionStatus("SubscriptionAuthCode", SubscriptionAuthCode); /// <summary> /// Call SubscriptionDetail operation return SubscriptionDetailResponse object /// </summary> /// <param name="MerchantSubscriptionId">MerchantSubscriptionId</param> /// <param name="ConsumerId">ConsumerId</param> SubscriptionDetailResponseObj.RootObject getSubscriptionDetail = payment.getSubscriptionDetail(getSubscriptionStatus.MerchantSubscriptionId, getSubscriptionStatus.ConsumerId); } }
/// <summary> /// Use the app account settings from developer.att.com for the following values. /// Make sure MIM,IMMN is enabled for the app key/secret /// </summary> protected void Page_Load(object sender, EventArgs e) { // Enter the value from the 'App Key' field obtained at developer.att.com in your // app account. string clientId = ""; // Enter the value from the 'App Secret' field obtained at developer.att.com // in your app account. string secretKey = ""; // Set the fully-qualified domain name to: https://api.att.com string fqdn = "https://api.att.com"; // Set the redirect URI for returning after consent flow. string authorizeRedirectUri = ""; //Set the scope to MIM,IMMN string scope = "MIM,IMMN"; //Create the service for requesting an OAuth access token. var oauth = new OAuth(fqdn, clientId, secretKey, authorizeRedirectUri, scope); // If there's no access token yet go through the concent flow. if (Request["code"] == null) { // Authenticate the user. Note: This requires a Web browser. // Obtain the url string that is used for consent flow. if (!oauth.GetAuthCode()) { //Get any error codes returned by the API Gateway. string authCodeError = oauth.getAuthCodeError; } } else { // Get code in the query parameters after doing consent flow oauth.authCode = Request["code"].ToString(); // Get the OAuth access token using the OAuth authentication code. if (oauth.GetAccessToken(OAuth.AccessTokenType.AuthorizationCode)) { // Get access token OAuthToken at = new OAuthToken(); var accessToken = at.getAccessToken(oauth.accessTokenJson); // Create the service for making the method request. var mymessages = new MyMessages(fqdn, accessToken); // Create an instance for JavaScriptSerializer. var serializer = new JavaScriptSerializer(); //************************************************************************* // Operation: Create Message Index // The Create Message Index method allows the developer to create an index // cache for the user's AT&T Message inbox with prior consent. try { // Make an Make a method call to the In-App Messaging API. // Method takes no param mymessages.createMessageIndex(); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Get Message List // Get meta-data for one or more messages from the customer's AT&T Message inbox. string limit = "<Enter limit>"; // e.g 500 string offset = "<Enter pffset>"; // e.g. 50 try { // Make a method call to the In-App Messaging API. // Method takes no param MessageObj.MessageList responseData = mymessages.getMessageList(limit, offset); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Get Message // Get one specific message from a user's AT&T Message inbox. var getMsg_messageId = "<Enter Message Id>"; try { // Make a method call to the In-App Messaging API. // Method takes: // param 1: string message id MessageObj.Message responseData = mymessages.getMessage(getMsg_messageId); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Get Message Content // Get media associated with a user message. string getMsgCtntMessageId = "<Enter Message Id>"; string getMsgCtntPartId = "<Enter Part Id>"; // e.g. 0 try { // Make a method call to the In-App Messaging API. // Method takes: // param 1: string message id // param 2: string part id string responseData = mymessages.getMessageContent(getMsgCtntMessageId, getMsgCtntPartId); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Get Message Index Info // Get the state, status, and message count of the index cache. try { // Make a method call to the In-App Messaging API. // Method takes no param string responseData = mymessages.getMessageIndexInfo(); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Delete Message // The Delete Message method gives the developer the ability to delete one // specific message from a user's AT&T Message inbox with prior consent. var delMsg_messageId = "<Enter Message Id>"; try { // Make a method call to the In-App Messaging API. // Method takes: // param 1: string message id mymessages.deleteMessage(delMsg_messageId); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Delete Messages // The Delete Message method gives the developer the ability to delete one // or more specific messages. var delMsg_messageId1 = "<Enter Message ID>"; var delMsg_messageId2 = "<Enter Message ID>"; var delMsg_messageId3 = "<Enter Message ID>"; var queryString = "messageIds=" + delMsg_messageId1 + "%2" + delMsg_messageId2 + "%2" + delMsg_messageId3; try { // Make a method call to the In-App Messaging API. // Method takes: // param 1: string query string mymessages.deleteMessage(queryString); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Get Message Delta // provides the capability to check for updates by passing in a client state. string state = "1403732028949"; try { // Make a method call to the In-App Messaging API. // Method takes no param string responseData = mymessages.getMessageDelta(state); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Get Message Notification Connection Details // Retrieves details about the credentials, endpoint, and resource information // to required to set up a notification connection. string queues = "MMS";//MMS or TEXT try { // Make a method call to the In-App Messaging API. // Method takes param 1: queues string responseData = mymessages.getMessageNotificationConnectionDetails(queues); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Send Message // The Send Message method sends messages on behalf of an AT&T Wireless user. //Convert Message request object to JSON string smAddress = "<Enter address>";//e.g. tel:2060000000 string smText = "<Enter messgae>"; // message content var addressesList = new List<string>(); addressesList.Add(smAddress); var sendMsgObj = new MessageRequestObj.RootObject() { messageRequest = new MessageRequestObj.MessageRequest() { addresses = addressesList, text = smText } }; var sendMsgJson = serializer.Serialize(sendMsgObj); try { // Make a method call to the In-App Messaging API. // Method takes: // param 1: string json mymessages.SendMessage(sendMsgJson); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Update Message // Update some flags related to one of the messages in a user's AT&T Message inbox. var isUnread = true; //Convert Message object to JSON var updateMsgObj = new MessageObj.RootObject() { message = new MessageObj.Message() { isUnread = isUnread } }; var updateMsgJson = serializer.Serialize(updateMsgObj); string umMessageId = "<Enter Message Id>"; try { // Make a method call to the In-App Messaging API. // Method takes: // param 1: string json // param 2: string message id mymessages.updateMessage(updateMsgJson, umMessageId); } catch (Exception ex) { string error = ex.Message; } //************************************************************************* // Operation: Update Messages // Update some flags related to one of the messages in a user's AT&T Message inbox. //Convert Message object to JSON bool umIsUnread = true; var umMessages = new List<MessageObj.Message>(); umMessages.Add(new MessageObj.Message() { messageId = "<Enter Message Id>", isUnread = umIsUnread }); var updateMsgsObj = new MessageObj.RootObject(); updateMsgsObj.messages = umMessages; var updateMsgsJson = serializer.Serialize(updateMsgsObj); try { // Make a method call to the In-App Messaging API. // Method takes: // param 1: string json mymessages.updateMessages(updateMsgsJson); } catch (Exception ex) { string error = ex.Message; } } } }
protected void Page_Load(object sender, EventArgs e) { // Enter the value from the 'App Key' field obtained at developer.att.com in your // app account. string clientId = ""; // Enter the value from the 'App Secret' field obtained at developer.att.com // in your app account. string secretKey = ""; // Set the fully-qualified domain name to: https://api.att.com string fqdn = "https://api.att.com"; // Set the scope to SPEECH,STTC,TTS string scope = "SPEECH,STTC,TTS"; // Create the service for requesting an OAuth access token. var oauth = new OAuth(fqdn, clientId, secretKey, scope); // Get the OAuth access token using the OAuth Client Credentials. if (oauth.GetAccessToken(OAuth.AccessTokenType.ClientCredentials)) { // Get access token OAuthToken at = new OAuthToken(); string accessToken = at.getAccessToken(oauth.accessTokenJson); // Create the service for making the method request. var speech = new Speech(fqdn, accessToken); //************************************************************************* // Operation: speech To Text // Set params: string sttXspeechContext = "BusinessSearch"; string sttXArgs = "ClientApp=NoteTaker,ClientVersion=1.0.1,DeviceType=Android"; string sttSpeechFilePath = Server.MapPath("~/") + "audio/BostonCeltics.wav"; bool sttChunked = true; try { // Make an Make a method call to the Speech To Text API. // Method takes: // Param 1: speechContext // Param 2: XArgs // Param 3: SpeechFilePath // Param 4: Chunked RecognitionObj.RootObject speachToTextResponseObj = speech.speechToText(sttXspeechContext, sttXArgs, sttSpeechFilePath, sttChunked); } catch (Exception respex) { string error = respex.StackTrace; } //************************************************************************* // Operation: Speech To Text Custom // Set params: string mimeData = System.IO.File.ReadAllText(Server.MapPath("~/") + "template/x-dictionary.txt"); string sttcXspeechContext = "GrammarList"; string sttcXArgs = "GrammarPenaltyPrefix=1.1,GrammarPenaltyGeneric=2.0,GrammarPenaltyAltgram=4.1"; string sttcSpeechFilePath = Server.MapPath("~/") + "audio/pizza-en-US.wav"; string xgrammerContent = string.Empty; string xdictionaryContent = string.Empty; StreamReader streamReader = new StreamReader(Server.MapPath("~/") + "template/x-dictionary.txt"); xdictionaryContent = streamReader.ReadToEnd(); mimeData = "x-dictionary:" + Environment.NewLine + xdictionaryContent; StreamReader streamReader1 = new StreamReader(Server.MapPath("~/") + "template/x-grammer.txt"); xgrammerContent = streamReader1.ReadToEnd(); mimeData = mimeData + Environment.NewLine + "x-grammar:" + Environment.NewLine + xgrammerContent; streamReader.Close(); streamReader1.Close(); //make speech to text custom request try { // Make an Make a method call to Speech To Text Custom. // Method takes: // Param 1: mimeData // Param 2: speechContext // Param 3: XArgs // Param 4: SpeechFilePath // Param 5: xdictionaryContent // Param 5: xgrammerContent RecognitionObj.RootObject speachToTextResponseCObj = speech.speechToTextCustom(mimeData, sttcXspeechContext, sttcXArgs, sttcSpeechFilePath, xdictionaryContent, xgrammerContent); } catch (Exception respex) { string error = respex.StackTrace; } //************************************************************************* // Operation: Text To Speech try { // Make an Make a method call to Text to Speech. // Method takes: // Param 1: test string byte[] responseAudioData = speech.textToSpeech("test"); } catch (Exception respex) { string error = respex.StackTrace; } } }
protected void Page_Load(object sender, EventArgs e) { // Enter the value from the 'App Key' field obtained at developer.att.com in your // app account. string clientId = ""; // Enter the value from the 'App Secret' field obtained at developer.att.com // in your app account. string secretKey = ""; // Set the fully-qualified domain name to: https://api.att.com string fqdn = "https://api.att.com"; //Set the scope to MMS string scope = "MMS"; //Create the service for requesting an OAuth access token. var oauth = new OAuth(fqdn, clientId, secretKey, scope); //Get the OAuth access token using client Credential method. if (oauth.GetAccessToken(OAuth.AccessTokenType.ClientCredentials)) { // Get access token OAuthToken at = new OAuthToken(); string accessToken = at.getAccessToken(oauth.accessTokenJson); // Create the service for making the method request. var mms = new MMS(fqdn, accessToken); // Set params: string mmsAddress = Server.UrlEncode("tel:10000000000") + "&"; //e.g.tel:1234567890 string mmsMessage = Server.UrlEncode("msg txt context"); string mmsFile = Server.MapPath("~/") + "attachments/att.jpg"; //Attachement path string mmsContentType = "image/jpeg"; string messageId = ""; try { // Make an Make a method call to the MMS API. // Method takes: // param 1: string mmsAddress (phone number(s)) // param 2: message text content // param 3: file path // param 4: multipart content type OutboundMessageResponseObj.RootObject SendMMSResponseObj = mms.sendMMS(mmsAddress, mmsMessage, mmsFile, mmsContentType); messageId = SendMMSResponseObj.outboundMessageResponse.messageId; } catch (Exception respex) { string error = respex.StackTrace; } try { // Make an Make a method call to the MMS API. // Method takes: // param 1: string message id DeliveryInfoObj.RootObject getStatusResponseObj = mms.getMMSDeliveryStatus(messageId); } catch (Exception respex) { string error = respex.StackTrace; } } }
protected void Page_Load(object sender, EventArgs e) { // Enter the value from the 'App Key' field obtained at developer.att.com in your // app account. string clientId = ""; // Enter the value from the 'App Secret' field obtained at developer.att.com // in your app account. string secretKey = ""; // Set the fully-qualified domain name to: https://api.att.com string fqdn = "https://api.att.com"; //Set the scope to AAB string scope = "Payment"; // Create the service for requesting an OAuth access token. var oauth = new OAuth(fqdn, clientId, secretKey, scope); // Get the OAuth access token using the Client Credentials. if (oauth.GetAccessToken(OAuth.AccessTokenType.ClientCredentials)) { // Get access token OAuthToken at = new OAuthToken(); string accessToken = at.getAccessToken(oauth.accessTokenJson); // Create the service for making the method request. var payment = new Payment(fqdn, accessToken); if (string.IsNullOrEmpty((string)Session["NewTransaction"])) { /// <summary> /// Create new transaction /// </summary> /// <param name="apiKey">apiKey</param> /// <param name="secretKey">secretKey</param> /// <param name="description">description</param> /// <param name="amount">amount</param> /// <param name="category">category</param> /// <param name="channel">channel</param> /// <param name="merchantRedirectURI">merchantRedirectURI</param> /// <param name="merchantProductId">merchantProductId</param> /// <param name="merchantTransactionId">merchantTransactionId</param> var redirectUrl = payment.createNewTransactionRedirectUrl( clientId, secretKey, "Sample Product", 0.01, 2, "MOBILE_WEB", "http://localhost/PaymentNewTransaction.aspx", "whateverprod", merchantTransactionId); Session["NewTransaction"] = "created"; Response.Redirect(redirectUrl); } if (Request.QueryString["success"] != null && Request.QueryString["success"].ToString() == "false") { errorCreateNew = new Dictionary <string, string>(); foreach (String key in Request.QueryString.AllKeys) { errorCreateNew.Add(key, Request.QueryString[key]); } throw new Exception(Request.QueryString["faultDescription"]); } if ((Request["TransactionAuthCode"] != null)) { TransactionAuthCode = Request.QueryString["TransactionAuthCode"].ToString(); } /// <summary> /// Call getTransactionStatus operation return getTransactionStatus object /// </summary> /// <param name="idType">idType</param> /// <param name="id">id</param> TransactionStatusResponseObj.RootObject getTransactionStatus = payment.getTransactionStatus("TransactionAuthCode", TransactionAuthCode); //Get Payment notification //Stream inputstream = Request.InputStream; //int streamLength = Convert.ToInt32(inputstream.Length); //byte[] stringArray = new byte[streamLength]; //inputstream.Read(stringArray, 0, streamLength); //string xmlString = System.Text.Encoding.UTF8.GetString(stringArray); string xmlString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ownershipEvent type=\"revoke\" timestamp=\"2014-05-02T06:12:33+00:00\" effective=\"2014-05-02T06:12:18+00:00\"><networkOperatorId>cingular</networkOperatorId><ownerIdentifier>N_NBI_PNW_1369816836000116729061</ownerIdentifier><purchaseDate>2014-05-02T06:12:05+00:00</purchaseDate><productIdentifier>Onetime_Cat1</productIdentifier><purchaseActivityIdentifier>Z89EZXmzjy2yu6s7wFY88cZM9lgztD6PRyo8</purchaseActivityIdentifier><instanceIdentifier>ada820f1-ce48-499b-8b46-eac60ef28a2a-CTASTransactionP1</instanceIdentifier><minIdentifier>4256586023</minIdentifier><sequenceNumber>178</sequenceNumber><reasonCode>1760</reasonCode><reasonMessage>CP Requested Refund</reasonMessage><vendorPurchaseIdentifier>M789819033</vendorPurchaseIdentifier></ownershipEvent>"; XmlSerializer deserializer = new XmlSerializer(typeof(ownershipEvent)); TextReader textReader = new StringReader(xmlString); ownershipEvent notificationObj; notificationObj = (ownershipEvent)deserializer.Deserialize(textReader); textReader.Close(); //create refund transaction object RefundTransactionRequestObj.RootObject refund = new RefundTransactionRequestObj.RootObject() { TransactionOperationStatus = "Refunded", RefundReasonCode = 1, RefundReasonText = "Customer was not happy" }; var serializer = new JavaScriptSerializer(); var refundJSON = serializer.Serialize(refund); RefundTransactionResponseObj.RootObject refundResponse = payment.RefundTransaction(refundJSON, getTransactionStatus.TransactionId); } }