Syntax
C#
[OperationContractAttribute()] SBT.API.DataContracts.Admin.WSSubscriberResponse UpdateSubscriber( string securityToken, SBT.API.DataContracts.Admin.SubscriberInfo subscriber )
WSDL
Production: https://ui.solutionsbytext.com/Sbt.App.SetUp/WSServices/subscriberWSService.svc?singleWsdl
Staging: https://test.solutionsbytext.com/Sbt.App.SetUp/WSServices/subscriberWSService.svc?singleWsdl
Parameters
securityToken
- String[1000] (Required) - SecurityToken to authenticate the user
SubscriberInfo
* MobilePhone - String[20] (Required) – Mobile phone number with country code.
* FName - String[100] (Optional) - First Name of a subscriber (private information).
* LName - String[100] (Optional) - Last Name of a subscriber (private information).
* Email - String[100] (Optional) – Email ID of a subscriber (private information).
* City - String[100] (Optional) - City of a subscriber (private information).
* Street - String[100] (Optional) - Street address of a subscriber (private information).
* Street2 - String[100] (Optional) – Street address of a subscriber (private information).
* ZipCode - String[10] (Optional) – Zip code of a subscriber (private information).
* CustomField1 - String[100] (Optional) - CustomField1 of a subscriber (private information).
* CustomField2 - String[100] (Optional) - CustomField2 of a subscriber (private information).
* CustomField3 - String[100] (Optional) - CustomField3 of a subscriber (private information).
* PrivateCode - String[100] (Optional) - PrivateCode of a subscriber (private information).
* UniqueID - String[100] (Optional) - UniqueID of a subscriber (private information).
Note: Please Use "UniqueID" field to update the subscriber unique id. "PrivateCode" is obsolete .
Return Value
WSSubscriberResponse
Name | Type | Description |
---|---|---|
Result | bool | True/False whether the call was successful or not. |
ErrorCode | int | For Sucees/Failure it returns an error number. |
Message | string | Message related to the error code |
Remarks
WSSubscriberResponse
Developer Tips
The UpdateSubscriber method provides the ability to associate a unique identifier (e.g. account number, customer number, application number, etc.) with the mobile phone number subscription in the Solutions by Text platform. This unique ID is then returned in reports, posts to the Status URL(s), and posts to the Callback URL(s).
The primary use case for UpdateSubscriber is mapping outbound / inbound messages back to the customer record / history.
Examples
C#
SubscriberClient subscriberService = new SubscriberClient("SubscriberWSServiceHttpEndpoint"); SubscriberInfo subscriber = new SubscriberInfo(); string securityToken = txtToken.Text; subscriber.MobilePhone = txtMobileNo.Text; subscriber.FName = txtFName.Text; subscriber.LName = txtLName.Text; subscriber.Email = txtEmail.Text; subscriber.City = txtCity.Text; subscriber.Street = txtStreet.Text; subscriber.Street2 = txtStreet2.Text; subscriber.ZipCode = txtZipcode.Text; subscriber.CustomField1 = txtCF1.Text; subscriber.CustomField2 = txtCF2.Text; subscriber.CustomField3 = txtCF3.Text; subscriber.PrivateCode = txtPrivateCode.Text; subscriber.UniqueID = txtPrivateCode.Text; WSSubscriberResponse wSSubscriberResponse = subscriberService.UpdateSubscriber(securityToken, subscriber); if (!wSSubscriberResponse.Result) { //handle error lblError.Text = wSSubscriberResponse.Message; } else { //handle success lblError.Text = wSSubscriberResponse.Message; }
SOAP
Soap Request <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://SBTService/ServiceContracts/" xmlns:ser1="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:dat="http://SBTAPIService/DataContract/"> <soapenv:Header/> <soapenv:Body> <ser:UpdateSubscriber> <!--Required:--> <ser:securityToken>Security Token</ser:securityToken> <ser:subscriber> <!--Required:--> <dat:MobilePhone>Mobile Number</dat:MobilePhone> <!--Optional:--> <dat:FName>First Name</dat:FName> <!--Optional:--> <dat:LName>Last Name</dat:LName> <!--Optional:--> <dat:Email>Email</dat:Email> <!--Optional:--> <dat:City>City</dat:City> <!--Optional:--> <dat:Street>Street 1</dat:Street> <!--Optional:--> <dat:Street2>Street 2</dat:Street2> <!--Optional:--> <dat:ZipCode>Zip code</dat:ZipCode> <!--Optional:--> <dat:CustomField1>Custom Field1</dat:CustomField1> <!--Optional:--> <dat:CustomField2>Custom Field2</dat:CustomField2> <!--Optional:--> <dat:CustomField3>Custom Field3</dat:CustomField3> <!--Optional:--> <dat:PrivateCode>Private Code</dat:PrivateCode> <!--Optional:--> <dat:UniqueID>Unique ID</dat:UniqueID> </ser:subscriber> </ser:UpdateSubscriber> </soapenv:Body> </soapenv:Envelope> Soap Response <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <UpdateSubscriberResponse xmlns="http://SBTService/ServiceContracts/"> <UpdateSubscriberResult z:Id="i1" xmlns:a="http://SBTAPIService/DataContract/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/"> <a:ErrorCode>1013</a:ErrorCode> <a:Message>Subscriber information saved successfully</a:Message> <a:Result>true</a:Result> </UpdateSubscriberResult> </UpdateSubscriberResponse> </s:Body> </s:Envelope>
JAVA
SubscriberWSService srv = new SubscriberWSService(); ISubscriber iSubscriber = srv.getSubscriberWSServiceHttpEndpoint1(); WSSubscriberResponse res = null; String securityToken = "securityToken"; SubscriberInfo subscriber = new SubscriberInfo(); subscriber.setMobilePhone(new JAXBElement(new QName("http://SBTAPIService/DataContract/", "MobilePhone"), new String("").getClass(),"1233456567768")); subscriber.setFName(new JAXBElement(new QName("http://SBTAPIService/DataContract/", "FName"), new String("").getClass(),"FName")); subscriber.setLName(new JAXBElement(new QName("http://SBTAPIService/DataContract/", "LName"), new String("").getClass(),"LName")); subscriber.setEmail(new JAXBElement(new QName("http://SBTAPIService/DataContract/", "Email"), new String("").getClass(),"[email protected]")); subscriber.setStreet(new JAXBElement(new QName("http://SBTAPIService/DataContract/", "Street"), new String("").getClass(),"Street")); subscriber.setStreet2(new JAXBElement(new QName("http://SBTAPIService/DataContract/", "Street2"), new String("").getClass(),"Street2")); subscriber.setZipCode(new JAXBElement(new QName("http://SBTAPIService/DataContract/", "ZipCode"), new String("").getClass(),"1234")); subscriber.setsetCustomField1(new JAXBElement(new QName("http://SBTAPIService/DataContract/", "setCustomField1"), new String("").getClass(),"setCustomField1")); subscriber.setCustomField2(new JAXBElement(new QName("http://SBTAPIService/DataContract/", "CustomField2"), new String("").getClass(),"CustomField2")); subscriber.setCustomField3(new JAXBElement(new QName("http://SBTAPIService/DataContract/", "CustomField3"), new String("").getClass(),"CustomField3")); subscriber.setPrivateCode(new JAXBElement(new QName("http://SBTAPIService/DataContract/", "PrivateCode"), new String("").getClass(),"PrivateCode")); subscriber.setUniqueID(new JAXBElement(new QName("http://SBTAPIService/DataContract/", "UniqueID"), new String("").getClass(),"UniqueID")); try { res = iSubscriber.UpdateSubscriber(securityToken, subscriber); } catch (Throwable e) { e.printStackTrace(); } if(res == null ){ System.out.println("::Error::"); return; } if (res.isResult() == null || !res.isResult()) { //handle error System.out.println("ErrorCode::"+res.getErrorCode()); System.out.println("ErrorMessage::"+res.getMessage().getValue()); } else { //handle success System.out.println("Message::"+res.getMessage().getValue()); }
PHP
<?php $client = new SoapClient("https://ui.solutionsbytext.com/Sbt.App.SetUp/wsservices/subscriberWSService.svc?wsdl"); $param = array( 'securityToken' =--> 'securityToken', 'subscriber ' => array( 'MobilePhone' => '123456789082', 'FName' => 'FName', 'LName' => 'LName', 'Email' => '[email protected]', 'City' => 'City', 'Street' => 'Street', 'Street2' => 'Street2', 'ZipCode' => '1235', 'CustomField1' => 'CustomField1', 'CustomField2' => 'CustomField2', 'CustomField3' => 'CustomField3', 'PrivateCode' => 'PrivateCode', 'UniqueID' => 'UniqueID', ) ); $response = $client->__soapCall('UpdateSubscriber', array($param)); echo '<pre?>'; print_r($response); if($response->UnpdateSubscribeResult->Result){ echo 'Message: '.$response->UnpdateSubscribeResult->Message; } else { echo 'Message: '.$response->UnpdateSubscribeResult->Message; } ?>
REST
Method: PUT
URL: https://ui.solutionsbytext.com/SBT.App.SetUp/RSServices/SubscriberRSService.svc/UpdateSubscriber
Sample C# Code:
SubscriberInfo subInfo = new SubscriberInfo { MobilePhone = "1234567891", FName = "FName", LName = "LName", Email = "[email protected]", City = "City", Street = "Street", Street2 = "Street2", ZipCode = "ZipCode", CustomField1 = "CustomField1", CustomField2 = "CustomField2", CustomField3 = "CustomField3", PrivateCode = "PrivateCode", UniqueID = "UniqueID" }; DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(SubscriberInfo)); MemoryStream mem = new MemoryStream(); ser.WriteObject(mem, subInfo); string data = Encoding.UTF8.GetString(mem.ToArray(), 0, (int)mem.Length); var requestdata = new { securityToken = "validsecurityToken", subscriber = subInfo }; string data2 = JsonConvert.SerializeObject(requestdata).ToString(); txtRequestFormat.Text = data2; System.Net.WebClient webClient = new System.Net.WebClient(); webClient.Headers["Content-type"] = "application/json"; webClient.Encoding = Encoding.UTF8; var strUpd = webClient.UploadString("https://ui.solutionsbytext.com/SBT.App.SetUp/RSServices/SubscriberRSService.svc/UpdateSubscriber", "PUT", data2);
Response:
The response will be in JSON format like below: {" UpdateSubscriberResult": { "Result": true, "ErrorCode": 1013, "Message": " Subscriber information saved successfully" }}