SetPostbackURLForPhoneNumber

From CDYNE Wiki
Jump to navigation Jump to search

Assign a PostbackURL to a specific DID or short code.

SetPostbackUrlForPhoneNumber Request

Parameter Name Data Type Sample Input Required
LicenseKey: License key associated with DID/short code.
Trial Key
Production Key
GUID f01d89fd-5155-5455-5585-e84ab8de8591 TRUE
PhoneNumber: DID/short code to enable URL. String 15551234567 TRUE
Country: Origin country of DID/short code. String US TRUE
PostbackType: Indicates whether PostBackURL is being used for incoming messages, outgoing messages, delivery receipts, or all messages associated with DID/short code. String All

Complete list of PostbackType values:

  • All
  • DeliveryReceipt
  • IncomingMessage
  • OutgoingMessage
TRUE
Url: URL SMS information is posted to. String http://www.cdyne.com/postback.aspx TRUE

SetPostbackUrlForPhoneNumber Response

Parameter Name Data Type Sample Output
ReturnCode: Indicates if an error occurred due to the data in the request. String No Error

Complete list of return codes:

  • NoError
  • InvalidLicenseKey
  • InvaildUrl
  • InvalidPhoneNumber
  • InvalidPostbackType
  • NotFound
  • InvalidCountry

HTTP GET Request

http://messaging.cdyne.com/Messaging.svc/SetPostbackUrlForPhoneNumber?LicenseKey=f01d89fd-5155-5455-5585-e84ab8de8591&PhoneNumber=15559080983&Country=US&PostBackType=All&URL=http://cdyne.com/postbackpage.aspx

Ruby

 1 require 'net/http'
 2 require 'URI' 
 3 
 4 puts URI.methods 
 5 
 6 url = URI.parse("http://messaging.cdyne.com/Messaging.svc/SetPostbackUrlForPhoneNumber?LicenseKey=f01d89fd-5155-5455-5585-e84ab8de8591&PhoneNumber=15559080983&Country=US&PostBackType=All&URL=http://cdyne.com/postbackpage.aspx")
 7 
 8 res = Net::HTTP.get_response(url) 
 9 
10 data = res.body 
11 
12 puts data
13 gets data

C#

 1 /*http://messaging.cdyne.com/Messaging.svc?wsdl was added as Service Reference and given the name WSDL*/
 2 
 3 using System;
 4 using System.Collections.Generic;
 5 using System.Linq;
 6 using System.Text;
 7 using System.Threading.Tasks;
 8 using SetPostBackURLForPhoneNumber.WSDL;
 9 
10 namespace SetPostBackURLForPhoneNumber
11 {
12     class Program
13     {
14         static void Main(string[] args)
15         {
16             MessagingClient client = new MessagingClient("mms2wsHttpBinding");
17 
18             SMSPostbackReturnCode resp = client.SetPostbackUrlForPhoneNumber(new Guid("f01d89fd-5155-5455-5585-e84ab8de8591"), "15559080983", "US", SMSPostbackType.All, "http://cdyne.com/postbackpage.aspx");
19 
20             Console.WriteLine("Error Setting Postback: " + resp);
21 
22             Console.ReadLine();
23         }
24     }
25 }

VB.Net

 1 'http://messaging.cdyne.com/Messaging.svc?wsdl was added as Service Reference and given the name WSDL
 2 
 3 Imports SetPostbackURLForPhoneNumber.WSDL
 4 
 5 Module Module1
 6 
 7     Sub Main()
 8 
 9         Dim client As WSDL.MessagingClient = New MessagingClient("mms2wsHttpBinding")
10 
11         Dim resp As Boolean = client.SetPostbackUrlForPhoneNumber(New Guid("f01d89fd-5155-5455-5585-e84ab8de8591"), "15559080983", "US", SMSPostbackType.All, "http://cdyne.com/postbackpage.aspx")
12 
13         Console.Write("Error Setting PostBack: " + Convert.ToString(resp))
14 
15         Console.ReadLine()
16 
17     End Sub
18 
19 End Module

PHP with cURL

 1 <?php
 2 
 3 $url='http://messaging.cdyne.com/Messaging.svc/SetPostbackUrlForPhoneNumber?LicenseKey=f01d89fd-5155-5455-5585-e84ab8de8591&PhoneNumber=15559080983&Country=US&PostBackType=All&URL=http://cdyne.com/postbackpage.aspx';
 4 
 5 $ch = curl_init(); 
 6 
 7 curl_setopt($ch,CURLOPT_URL,$url);
 8 curl_setopt($ch,CURLOPT_HTTPGET,true);
 9 curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);  
10 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Accept: application/json'));
11 
12 //print_r($url);
13 
14 $response = curl_exec($ch); 
15 curl_close($ch); 
16 
17 print_r($response);
18 
19 ?>

VBScript

 1 Dim oXMLHTTP
 2 Set oXMLHTTP = CreateObject("Microsoft.XMLHTTP")
 3 Set oDoc = CreateObject("MSXML2.DOMDocument")
 4 
 5 Call oXMLHttp.Open("GET", "http://messaging.cdyne.com/Messaging.svc/SetPostbackUrlForPhoneNumber?LicenseKey=f01d89fd-5155-5455-5585-e84ab8de8591&PhoneNumber=15559080983&Country=US&PostBackType=All&URL=http://cdyne.com/postbackpage.aspx", False)
 6 Call oXMLHttp.setRequestHeader("Content-Type", "text/xml")
 7 Call oXMLHttp.send
 8 
 9 MsgBox oXMLHTTP.responseText
10 
11 Const ForReading = 1, ForWriting = 2, ForAppending = 8
12 Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
13 Dim fso, MyFile, FileName, TextLine
14 Set fso = CreateObject("Scripting.FileSystemObject")
15 FileName = "c:\Users\Desktop\MMS.txt"
16 Set MyFile = fso.OpenTextFile(FileName, ForWriting, True)
17 MyFile.WriteLine oXMLHttp.responseText
18 MyFile.Close
19 Set MyFile = fso.OpenTextFile(FileName, ForReading)
20 Do While MyFile.AtEndOfStream <> True
21 TextLine = MyFile.ReadLine
22 Loop
23 
24 MyFile.Close  
25 
26 set request = nothing

JAVA

 1 import java.io.ByteArrayOutputStream;
 2 import java.io.InputStream;
 3 import java.net.MalformedURLException;
 4 import java.net.URL;
 5 import java.util.Properties;
 6 import javax.xml.transform.OutputKeys;
 7 import javax.xml.transform.Source;
 8 import javax.xml.transform.Transformer;
 9 import javax.xml.transform.TransformerFactory;
10 import javax.xml.transform.stream.StreamResult;
11 import javax.xml.transform.stream.StreamSource;
12 
13 public final class SetPostbackUrlForPhoneNumber {
14 
15     public static void main(String[] args) {
16 
17         try {
18 
19             URL url = new URL("http://messaging.cdyne.com/Messaging.svc/SetPostbackUrlForPhoneNumber?"
20                     + "LicenseKey=f01d89fd-5155-5455-5585-e84ab8de8591"
21                     + "&PhoneNumber=15553369037"
22                     + "&Country=US"
23                     + "&PostBackType=All"
24                     + "&Url=http://cdyne.com/postbackpage.aspx");
25             try {
26                 InputStream in = url.openStream();
27                 StreamSource source = new StreamSource(in);
28                 printResult(source);
29             } catch (java.io.IOException e) {
30             }
31         } catch (MalformedURLException e) {
32         }
33     }
34 
35     private static void printResult(Source source) {
36         try {
37             ByteArrayOutputStream bos = new ByteArrayOutputStream();
38             StreamResult sr = new StreamResult(bos);
39             Transformer trans = TransformerFactory.newInstance().newTransformer();
40             Properties oprops = new Properties();
41             oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
42             trans.setOutputProperties(oprops);
43             trans.transform(source, sr);
44             System.out.println("**** Response ******");
45             System.out.println(bos.toString());
46 
47             bos.close();
48             System.out.println();
49         } catch (Exception e) {
50         }
51     }
52 }