Create and add media to your SMS Notify! license key from the Base64
representation of the image.
Parameter Name |
Data Type |
Sample Input |
Required |
---|---|---|---|
Bae64EncodedContent: String representation of media. |
String |
\/9j\/4AAQSkZJRgABAQAAAQABAAD\ |
TRUE |
FileName: Name of media file being created. |
String |
MonkeyPic.jpg |
TRUE |
LicenseKey: License key attached to media file. |
GUID |
f01d89fd-5155-5455-5585-e84ab8de8591 |
TRUE |
Tag: Category of new media. |
String |
Monkey |
FALSE |
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 | MonkeyPic.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 |
The following is an example POST request using
http://messaging.cdyne.com/Messaging.svc/CreateMediaFromContent
{
"Base64EncodedContent":"aa/9j/4AAQSkZJRgABAQAAAQABAAD/2Q==",
"Filename":"monkey.jpg",
"LicenseKey":"f01d89fd-5155-5455-5585-e84ab8de8591",
"Tags":["Monkey"]
}
require 'uri'
require 'net/http'
url = URI("http://messaging.cdyne.com/Messaging.svc/CreateMediaFromContent")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = '{
"Base64EncodedContent":"aa/9j/4AAQSkZJRgABAQAAAQABAAD/2Q==",
"Filename":"monkey.jpg",
"LicenseKey":"f01d89fd-5155-5455-5585-e84ab8de8591",
"Tags":["Monkey"]}'
response = http.request(request)
puts response.read_body
gets response.read_body
/*http://messaging.cdyne.com/Messaging.svc?wsdl was added as Service Reference and given the name WSDL*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CreateMediaFromContent.WSDL;
namespace CreateMediaFromContent
{
class Program
{
static void Main(string[] args)
{
MessagingClient client = new MessagingClient("mms2wsHttpBinding");
CreateMediaContentRequest req = new CreateMediaContentRequest();
req.Base64EncodedContent = "aa/9j/4AAQSkZJRgABAQAAAQABAAD/2Q==";
req.Filename = "Monkey14.jpg";
req.LicenseKey = new Guid("f01d89fd-5155-5455-5585-e84ab8de8591");
req.Tags = new string[] {"Monkey"};
MediaMetadata resp = client.CreateMediaFromContent(req);
Console.WriteLine("UTC File Date: " + resp.FileDate + Environment.NewLine +
"File Name: " + resp.FileName + Environment.NewLine +
"File Size: " + resp.FileSize + Environment.NewLine +
"Media ID: " + resp.MediaId + Environment.NewLine +
"Mime Type: " + resp.MimeType);
foreach (var item in resp.Tags)
{
Console.Write("{0}", "Tags: " + item + Environment.NewLine + Environment.NewLine);
}
Console.ReadLine();
}
}
}
'http://messaging.cdyne.com/Messaging.svc?wsdl was added as Service Reference and given the name WSDL
Imports CreateMediaFromContent.WSDL
Module Module1
Sub Main()
Dim client As WSDL.MessagingClient = New MessagingClient("mms2wsHttpBinding")
Dim req As New WSDL.CreateMediaContentRequest()
req.Base64EncodedContent = "aa/9j/4AAQSkZJRgABAQAAAQABAAD/2Q=="
req.Filename = "VBNetMonkey.jpg"
req.LicenseKey = New Guid("f01d89fd-5155-5455-5585-e84ab8de8591")
req.Tags = New String() {"Monkey"}
Dim resp As WSDL.MediaMetadata = client.CreateMediaFromContent(req)
Console.WriteLine("UTC File Date: " + Convert.ToString(resp.FileDate) + Environment.NewLine +
"File Name: " + resp.FileName + Environment.NewLine +
"File Size: " + Convert.ToString(resp.FileSize) + Environment.NewLine +
"Media ID: " + Convert.ToString(resp.MediaId) + Environment.NewLine +
"Mime Type: " + resp.MimeType)
For Each item In resp.Tags
Console.WriteLine("Tags: " + item + Environment.NewLine + Environment.NewLine)
Next
Console.ReadLine()
End Sub
End Module
<?php
$json='{
"Base64EncodedContent":"aa/9j/4AAQSkZJRgABAQAAAQABAAD/2Q==",
"Filename":"monkey.jpg",
"LicenseKey":"f01d89fd-5155-5455-5585-e84ab8de8591",
"Tags":["Monkey"]
}';
$url='http://messaging.cdyne.com/Messaging.svc/CreateMediaFromContent';
$cURL = curl_init();
curl_setopt($cURL,CURLOPT_URL,$url);
curl_setopt($cURL,CURLOPT_POST,true);
curl_setopt($cURL,CURLOPT_POSTFIELDS,$json);
curl_setopt($cURL,CURLOPT_RETURNTRANSFER, true);
curl_setopt($cURL, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Accept: application/json'));
//If you desire your results in xml format, use the following line for your httpheaders and comment out the httpheaders code line above.
//curl_setopt($cURL, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$result = curl_exec($cURL);
curl_close($cURL);
$array = json_decode($result, true);
//print_r($json);
//print_r("\n\n\n\n");
print_r($array);
?>
Dim cXML
cXML = "<CreateMediaContentRequest xmlns=""http://sms2.cdyne.com"">" & _
"<Base64EncodedContent>aa/9j/4AAQSkZJRgABAQAAAQABAAD/2Q==</Base64EncodedContent>" & _
"<Filename>vbsmonkey.jpg</Filename>" & _
"<LicenseKey>f01d89fd-5155-5455-5585-e84ab8de8591</LicenseKey>" & _
"<Tags>" & _
"<string xmlns=""http://schemas.microsoft.com/2003/10/Serialization/Arrays"">vbstest</string>" & _
"</Tags>" & _
"</CreateMediaContentRequest>"
Dim oXMLHTTP
Set oXMLHTTP = CreateObject("Microsoft.XMLHTTP")
Set oDoc = CreateObject("MSXML2.DOMDocument")
Call oXMLHttp.Open("POST", "http://messaging.cdyne.com/Messaging.svc/CreateMediaFromContent", False)
Call oXMLHttp.setRequestHeader("Content-Type", "text/xml")
Call oXMLHttp.send(cXML)
MsgBox oXMLHTTP.responseText
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fso, MyFile, FileName, TextLine
Set fso = CreateObject("Scripting.FileSystemObject")
FileName = "c:\Users\Desktop\MMS.txt"
Set MyFile = fso.OpenTextFile(FileName, ForWriting, True)
MyFile.WriteLine oXMLHttp.responseText
MyFile.Close
Set MyFile = fso.OpenTextFile(FileName, ForReading)
Do While MyFile.AtEndOfStream <> True
TextLine = MyFile.ReadLine
Loop
MyFile.Close
set request = nothing
import java.io.File;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.HttpURLConnection;
import org.apache.commons.io.IOUtils;
public final class CreateMediaFromContent {
public static void main(String[] args) throws Exception {
String responseContent = "";
String response = "";
String decoded = IOUtils.toString(new FileInputStream(new File("C:\\Users\\Desktop\\Base64.txt")), "UTF-8");
URL url = new URL("http://messaging.cdyne.com/Messaging.svc/CreateMediaFromContent");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
StringBuilder sb = new StringBuilder("<CreateMediaContentRequest xmlns=\"http://sms2.cdyne.com\">");
sb.append("<Base64EncodedContent>").append(decoded).append("</Base64EncodedContent>");
sb.append("<Filename>JavaMonkey.jpg</Filename>");
sb.append("<LicenseKey>f01d89fd-5155-5455-5585-e84ab8de8591</LicenseKey>");
sb.append("<Tags>");
sb.append("<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">Monkey</string>");
sb.append("</Tags>");
sb.append("</CreateMediaContentRequest>");
connection.setRequestProperty("Content-Length", String.valueOf(sb.toString().length()));
connection.setRequestProperty("Content-Type", "text/xml");
connection.setRequestProperty("Connection", "Close");
connection.setRequestProperty("SoapAction", "");
connection.setRequestMethod("POST");
connection.setDoInput(true);
connection.setDoOutput(true);
PrintWriter pw = new PrintWriter(connection.getOutputStream());
pw.write(sb.toString());
pw.flush();
connection.connect();
System.out.println(sb.toString());
BufferedReader br;
if (connection.getResponseCode() == 200) {
br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
} else {
br = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
}
while ((responseContent = br.readLine()) != null) {
response += responseContent;
}
System.out.println(response);
}
}