GetMediaInfo

From CDYNE Wiki
Jump to navigation Jump to search

Retrieve info of a particular media file that was added to your SMS Notify! license key.

GetMediaInfo Request

Parameter Name Data Type Sample Input Required
EndDate: Most recent UTC date and time media was added to license key. DateTime 1999-05-31T11:20:00 FALSE
FileType: File type of media. String .jpg FALSE
FilenamePattern: Name of media file. String Monkey.jpg FALSE
(If MediaID is provided.)
IncomingMessageID: Unique ID associated to incoming message with media file. GUID 1627aea5-8e0a-4371-9022-9b504344e724 FALSE
LicenseKey: License key associated with media file.
Trial Key
Production Key
GUID f01d89fd-5155-5455-5585-e84ab8de8591 TRUE
MaximumFileSize: Largest file size of media. Int 97465 FALSE
MediaId: Unique ID for specific media file. Int 12487
OutgoingMessageID: Unique ID associated to outgoing message with media file. GUID 1627aea5-8e0a-4371-9022-9b504344e724 FALSE
PageNumber: Page number where media file is stored. Int 0 FALSE
PageSize: Number of media files per page. Int 0 FALSE
StartDate: Earliest UTC date and time media was added to license key. DateTime 1999-05-31T11:20:00 FALSE
Tag: Category of media file. String Monkey FALSE

GetMediaInfo Response

Parameter Name Data Type Sample Output
FileDate: UTC date and time media was created. DateTime 1999-05-31T11:20:00
FilenName: Name of media file. String Monkey.jpg
FileSize: Size of media file.. Int 97465
MediaId: Unique ID for specific media file. Int 12487
MimeType: Media file type. String image/jpeg
Tag: Category of media file. String Monkey

JSON Request

The following is an example POST request using http://messaging.cdyne.com/Messaging.svc/GetMediaInfo

{
    "EndDate":"\/Date(1506716393060+0000)\/",
    "FileType":".jpg",
    "FilenamePattern":"monkey.jpg",
    "IncomingMessageId": {{$guid}},
    "LicenseKey": "f01d89fd-5155-5455-5585-e84ab8de8591",
    "MaximumFileSize": 97465,
    "MediaId":0001,
    "MinimumFileSize":0,
    "OutgoingMessageId": {{$guid}},
    "PageNumber": 0,
    "PageSize":0,
    "StartDate":"\/Date(1506716393060+0000)\/",
    "Tags":["Monkey"]
}

Ruby

 1 require 'uri'
 2 require 'net/http'
 3 
 4 url = URI("http://messaging.cdyne.com/Messaging.svc/GetMediaInfo")
 5 
 6 http = Net::HTTP.new(url.host, url.port)
 7 
 8 request = Net::HTTP::Post.new(url)
 9 
10 request["content-type"] = 'application/json'
11 
12 request.body = '{
13 "EndDate":"\/Date(1571954141000+0000)\/",
14 "FileType":".jpg",
15 "FilenamePattern":"monkey1.jpg",
16 "LicenseKey": "f01d89fd-5155-5455-5585-e84ab8de8591",
17 "MaximumFileSize": 97465,
18 "MediaId": 11777,
19 "MinimumFileSize":0,
20 "PageNumber": 0,
21 "PageSize":0,
22 "StartDate":"\/Date(1507040885700+0000)\/",
23 "Tags":["Monkey"]}'
24 
25 response = http.request(request)
26 
27 puts response.read_body
28 gets response.read_body

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 GetMediaInfo.WSDL;
 9 
10 namespace GetMediaInfo
11 {
12     class Program
13     {
14         static void Main(string[] args)
15         {
16             MessagingClient client = new MessagingClient("mms2wsHttpBinding");
17             MediaCriteria req = new MediaCriteria();
18 
19             req.EndDate = new DateTime(2017, 10, 05, 23, 00, 0).ToUniversalTime();
20             req.FileType = ".jpg";
21             req.FilenamePattern = "monkey.jpg";
22             req.IncomingMessageId = new Guid();
23             req.LicenseKey = new Guid("f01d89fd-5155-5455-5585-e84ab8de8591");
24             req.MaximumFileSize = 97465;
25             req.MediaId = 0001;
26             req.MinimumFileSize = 0;
27             req.OutgoingMessageId = new Guid();
28             req.PageNumber = 0;
29             req.PageSize = 0;
30             req.StartDate = new DateTime(2017, 10, 01, 14, 15, 0).ToUniversalTime();
31             req.Tags = new string[] { "Monkey" };
32 
33             MediaReply resp = client.GetMediaInfo(req);
34 
35             foreach (var item in resp.Media)
36             {
37                 Console.WriteLine("File Date: " + item.FileDate + Environment.NewLine +
38                     "FileName: " + item.FileName + Environment.NewLine +
39                     "File Size: " + item.FileName + Environment.NewLine +
40                     "Media ID: " + item.MediaId + Environment.NewLine +
41                     "Media Type: " + item.MimeType);
42 
43                 if (item.Tags != null)
44                 {
45                     foreach (var media in item.Tags)
46                     {
47                         Console.WriteLine("Tags: " + media + Environment.NewLine + Environment.NewLine);
48                     }
49                 }
50             }
51         }
52     }
53 }

VB.Net

 1 'http://messaging.cdyne.com/Messaging.svc?wsdl was added as Service Reference and given the name WSDL
 2 
 3 Imports GetMediaInfo.WSDL
 4 
 5 Module Module1
 6 
 7     Sub Main()
 8 
 9         Dim client As WSDL.MessagingClient = New MessagingClient("mms2wsHttpBinding")
10 
11         Dim req As New WSDL.MediaCriteria()
12 
13         req.EndDate = New DateTime(2017, 10, 5, 23, 0, 0).ToUniversalTime()
14         req.FileType = ".jpg"
15         req.FilenamePattern = "Monkey33.jpg"
16         req.IncomingMessageId = New Guid()
17         req.LicenseKey = New Guid("f01d89fd-5155-5455-5585-e84ab8de8591")
18         req.MaximumFileSize = 97465
19         req.MediaId = 12242
20         req.MinimumFileSize = 0
21         req.OutgoingMessageId = New Guid()
22         req.PageNumber = 0
23         req.PageSize = 0
24         req.StartDate = New DateTime(2017, 10, 1, 14, 15, 0).ToUniversalTime()
25         req.Tags = New String() {"Monkey"}
26 
27         Dim resp As MediaReply = client.GetMediaInfo(req)
28 
29         For Each item In resp.Media
30 
31             Console.WriteLine("File Date: " + Convert.ToString(item.FileDate) + Environment.NewLine +
32                     "FileName: " + item.FileName + Environment.NewLine +
33                     "File Size: " + item.FileName + Environment.NewLine +
34                     "Media ID: " + Convert.ToString(item.MediaId) + Environment.NewLine +
35                     "Media Type: " + item.MimeType)
36 
37             For Each tag In item.Tags
38 
39                 If item.Tags.Length > 0 Then
40 
41                     Console.WriteLine("Tags: " + tag + Environment.NewLine + Environment.NewLine)
42 
43                 End If
44 
45             Next
46 
47         Next
48 
49         Console.ReadLine()
50 
51     End Sub
52 
53 End Module

PHP with cURL

 1 <?php
 2 
 3 $json='{
 4 	"EndDate":"\/Date(1507040885700+0000)\/",
 5     	"FileType":".jpg",
 6     	"FilenamePattern":"monkey1.jpg",
 7 	"LicenseKey":"f01d89fd-5155-5455-5585-e84ab8de8591",
 8 	"MaximumFileSize": 97465,
 9     	"MediaId": 11777,
10     	"MinimumFileSize":0,
11         "PageNumber": 0,
12         "PageSize":0,
13     	"StartDate":"\/Date(1507040885700+0000)\/",
14     	"Tags":["Monkey"]
15 }';
16 
17 $url='http://messaging.cdyne.com/Messaging.svc/GetMediaInfo';
18 $cURL = curl_init();
19  
20 curl_setopt($cURL,CURLOPT_URL,$url);
21 curl_setopt($cURL,CURLOPT_POST,true);
22 curl_setopt($cURL,CURLOPT_POSTFIELDS,$json);
23 curl_setopt($cURL,CURLOPT_RETURNTRANSFER, true);  
24 curl_setopt($cURL, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Accept: application/json'));
25 //If you desire your results in xml format, use the following line for your httpheaders and comment out the httpheaders code line above.
26 //curl_setopt($cURL, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); 
27 $result = curl_exec($cURL);
28 
29 curl_close($cURL);
30 
31 $array = json_decode($result, true);
32 //print_r($json);
33 //print_r("\n\n\n\n");
34 
35 print_r($array);
36 
37 ?>

VBScript

 1 Dim cXML
 2 cXML = "<MediaCriteria xmlns=""http://sms2.cdyne.com"">" & _
 3   "<EndDate>2017-10-20T11:20:00</EndDate>" & _
 4   "<FileType>.jpg</FileType>" & _
 5   "<FilenamePattern>monkey1.jpg</FilenamePattern>" & _
 6   "<LicenseKey>f01d89fd-5155-5455-5585-e84ab8de8591</LicenseKey>" & _
 7   "<MaximumFileSize>97465</MaximumFileSize>" & _
 8   "<MediaId>11777</MediaId>" & _
 9   "<MinimumFileSize>0</MinimumFileSize>" & _
10   "<PageNumber>0</PageNumber>" & _
11   "<PageSize>0</PageSize>" & _
12   "<StartDate>2017-10-01T11:20:00</StartDate>" & _
13   "<Tags>" & _
14     "<string xmlns=""http://schemas.microsoft.com/2003/10/Serialization/Arrays"">Monkey</string>" & _
15   "</Tags>" & _
16 "</MediaCriteria>"
17 
18 Dim oXMLHTTP
19 Set oXMLHTTP = CreateObject("Microsoft.XMLHTTP")
20 Set oDoc = CreateObject("MSXML2.DOMDocument")
21 Call oXMLHttp.Open("POST", "http://messaging.cdyne.com/Messaging.svc/GetMediaInfo", False)
22 Call oXMLHttp.setRequestHeader("Content-Type", "text/xml")        
23 Call oXMLHttp.send(cXML)
24 
25 MsgBox oXMLHTTP.responseText 
26 Const ForReading = 1, ForWriting = 2, ForAppending = 8
27 Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
28 Dim fso, MyFile, FileName, TextLine
29 Set fso = CreateObject("Scripting.FileSystemObject")
30 FileName = "c:\Users\Desktop\MMS.txt"
31 Set MyFile = fso.OpenTextFile(FileName, ForWriting, True)
32 MyFile.WriteLine oXMLHttp.responseText
33 MyFile.Close
34 Set MyFile = fso.OpenTextFile(FileName, ForReading)
35 Do While MyFile.AtEndOfStream <> True
36 TextLine = MyFile.ReadLine
37 Loop
38 MyFile.Close
39 
40 set request = nothing

JAVA

 1 import java.io.BufferedReader;
 2 import java.io.InputStreamReader;
 3 import java.io.PrintWriter;
 4 import java.net.HttpURLConnection;
 5 import java.net.URL;
 6 
 7 public final class GetMediaInfo {
 8 
 9     public static void main(String[] args) throws Exception {
10         String responseContent = "";
11         String response = "";
12 
13         URL url = new URL("http://messaging.cdyne.com/Messaging.svc/GetMediaInfo");
14         HttpURLConnection connection = (HttpURLConnection) url.openConnection();
15 
16         StringBuilder sb = new StringBuilder("<MediaCriteria xmlns=\"http://sms2.cdyne.com\">");
17         sb.append("<EndDate>2017-10-20T11:20:00</EndDate>");
18         sb.append("<FileType>.jpg</FileType>");
19         sb.append("<FilenamePattern>monkey1.jpg</FilenamePattern>");
20         sb.append("<LicenseKey>f01d89fd-5155-5455-5585-e84ab8de8591</LicenseKey>");
21         sb.append("<MaximumFileSize>97465</MaximumFileSize>");
22         sb.append("<MediaId>11777</MediaId>");
23         sb.append("<MinimumFileSize>0</MinimumFileSize>");
24         sb.append("<PageNumber>0</PageNumber>");
25         sb.append("<PageSize>0</PageSize>");
26         sb.append("<StartDate>2017-10-01T11:20:00</StartDate>");
27         sb.append("<Tags>");
28         sb.append("<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">Monkey</string>");
29         sb.append("</Tags>");
30         sb.append("</MediaCriteria>");
31 
32         connection.setRequestProperty("Content-Length", String.valueOf(sb.toString().length()));
33         connection.setRequestProperty("Content-Type", "text/xml");
34         connection.setRequestProperty("Connection", "Close");
35         connection.setRequestProperty("SoapAction", "");
36         connection.setRequestMethod("POST");
37         connection.setDoInput(true);
38         connection.setDoOutput(true);
39 
40         PrintWriter pw = new PrintWriter(connection.getOutputStream());
41         pw.write(sb.toString());
42         pw.flush();
43         connection.connect();
44         System.out.println(sb.toString());
45         BufferedReader br;
46 
47         if (connection.getResponseCode() == 200) {
48             br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
49         } else {
50             br = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
51         }
52 
53         while ((responseContent = br.readLine()) != null) {
54             response += responseContent;
55         }
56         System.out.println(response);
57     }
58 }