Overview
This method subscribes a phone number to a specified group, but if the phone number is already in the group, then it will return an error stating that Subscriber information already exists in the system. This method allows Division and Organization Org codes also. If Division or Organization code is used, then subscription will be created under all groups.
Note: This method must be configured for utilization, hence before using this method please contact the Solutions by Text team.
Syntax
C#
[OperationContractAttribute()] SBT.API.DataContracts.Admin.WSsubscriberResponse Subscribe( string securityToken, SBT.API.DataContracts.Admin.SubscriberDetails 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
subscriber
* MobilePhone - String[20] (Required) - MobilePhone number with country code.
OrgCode
- String[20] (Required) - Default Organization Code for Group, Division or Organization to which the subscription is made. If Division or Organization OrgCode is used, then subscription will be created under all groups.
Return Value
WSsubscriberResponse
Name | Type | Description |
---|---|---|
Result | bool | True/False whether the call was successful or not. |
ErrorCode | int | For Success/Failure it retuns an error number. |
Message | string | Message related to the error code. |
Remarks
WSsubscriberResponse
Developer Tips
The Subscribe method should be used in special cases and requires approval from the Solutions by Text team. Unlike the RequestVBT() and RequireVBT() API calls, Subscribe completes an opt-in but does not send an opt-in confirmation message to the recipient.
Examples
C#
SubscriberClient subscriberResult = new SubscriberClient("SubscriberWSServiceHttpEndpoint"); string securityToken = txtToken.Text; ; SubscriberDetails subscriber = new SubscriberDetails(); subscriber.MobilePhone = txtMobileNo.Text; subscriber.OrgCode = txtOrgCode.Text; WSSubscriberResponse wsSubscribeResponse = subscriberResult.Subscribe(securityToken, subscriber); if (!wsSubscribeResponse.Result) { //handle error lblError.Text = wsSubscribeResponse.Message; } else { //handle success lblError.Text = wsSubscribeResponse.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:Subscribe> <!--Required:--> <ser:securityToken>Security Token</ser:securityToken> <ser:subscriber> <!--Required:--> <dat:MobilePhone>Mobile number</dat:MobilePhone> <!--Required:--> <dat:OrgCode>Org code of Group, Division or Organization</dat:OrgCode> </ser:subscriber> </ser:Subscribe> </soapenv:Body> </soapenv:Envelope> Soap Response <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <SubscribeResponse xmlns="http://SBTService/ServiceContracts/"> <SubscribeResult 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>1016</a:ErrorCode> <a:Message>Subscriber information saved successfully</a:Message> <a:Response z:Id="i2"> <a:FirstName/> <a:LastName/> <a:MobilePhone>MobilePhone</a:MobilePhone> <a:SubcribeDate>2013-09-30T00:00:00</a:SubcribeDate> <a:UnSubcribedate>2013-10-10T00:00:00</a:UnSubcribedate> <a:SubscribedType>5</a:SubscribedType> <a:StateAbbr/> <a:City/> <a:Street/> <a:Street2/> </a:Zip> </a:Response> <a:Result>true</a:Result> </SubscribeResult> </SubscribeResponse> </s:Body> </s:Envelope>
REST
Method: POST
URL: https://ui.solutionsbytext.com/SBT.App.SetUp/RSServices/SubscriberRSService.svc/Subscribe
Sample C# Code:
SubscriberDetails subDetails = new SubscriberDetails { OrgCode = "OrgCode", FirstName = "FirstName", LastName = "LastName", MobilePhone = "1234567891", LandLine = "10016789101", Email = "[email protected]", SubcribeDate = DateTime.Now, UnSubcribedate = DateTime.Now, SubscribedType = 0, StateAbbr = "StateAbbr", City = "City", Street = "Street", Street2 = "Street2", Zip = "Zip", }; DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(SubscriberDetails)); MemoryStream mem = new MemoryStream(); ser.WriteObject(mem, subDetails); string data = Encoding.UTF8.GetString(mem.ToArray(), 0, (int)mem.Length); var requestdata = new { securityToken = "ValidSecurityToken", subscriber = subDetails }; 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/Subscribe", "POST", data2); Note: Above “strUpd” reponse contains the output response in JSON format.
Response:
The response will be in JSON format like below: {" SubscribeResult": { "Result": true, "ErrorCode": 1013, "Message": " Subscriber information saved successfully" }}