Retrieve the Base64 representation of a particular media file that was
added to your SMS Notify! license key.
Parameter Name |
Data Type |
Sample Input |
Required |
---|---|---|---|
LicenseKey: License key attached to media file. |
GUID |
f01d89fd-5155-5455-5585-e84ab8de8591 |
TRUE |
MediaID: Unique ID of specific media file.. |
Int |
1772 |
TRUE |
Parameter Name | Data Type | Sample Output |
---|---|---|
N/A | Base64 String | \/9j\/4AAQSkZJRgABAQAAAQABAAD\ |
http://messaging.cdyne.com/Messaging.svc/GetMedia?LicenseKey=f01d89fd-5155-5455-5585-e84ab8de8591&MediaId=0001
require 'net/http'
require 'URI'
puts URI.methods
url = URI.parse("http://messaging.cdyne.com/Messaging.svc/GetMedia?LicenseKey=f01d89fd-5155-5455-5585-e84ab8de8591&MediaId=0001")
res = Net::HTTP.get_response(url)
data = res.body
puts data
gets data
//The Base64 representation of the image will be printed in the console app window.
/*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 GetMedia.WSDL;
using System.IO;
namespace GetMedia
{
class Program
{
static void Main(string[] args)
{
MessagingClient client = new MessagingClient("mms2wsHttpBinding");
string resp = client.GetMedia(new Guid("f01d89fd-5155-5455-5585-e84ab8de8591"), 0001);
Console.WriteLine(resp);
Console.ReadLine();
}
}
}
//Option to save the actual media. The media will automatically saved to the location you specified.
/*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 GetMedia.WSDL;
using System.IO;
using System.Diagnostics;
namespace GetMedia
{
class Program
{
static void Main(string[] args)
{
string path = @"C:\Users\Desktop\image1.jpg";
MessagingClient client = new MessagingClient("mms2wsHttpBinding");
string resp = client.GetMedia(new Guid("f01d89fd-5155-5455-5585-e84ab8de8591"), 001);
var imagetest = Convert.FromBase64String(resp);
File.WriteAllBytes(path, imagetest);
Console.WriteLine("Image Saved");
Console.ReadLine();
}
}
}
//Option to display the actual media. The media will automatically display when running the code and the image will be saved to the location you specified.
/*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 GetMedia.WSDL;
using System.IO;
using System.Diagnostics;
namespace GetMedia
{
class Program
{
static void Main(string[] args)
{
MessagingClient client = new MessagingClient("mms2wsHttpBinding");
var info = client.GetMediaInfo(new MediaCriteria() { MediaId = 001, LicenseKey = new Guid("f01d89fd-5155-5455-5585-e84ab8de8591") });
var content = client.GetMedia(new Guid("f01d89fd-5155-5455-5585-e84ab8de8591"), 001);
var contentBytes = Convert.FromBase64String(content);
var filename = $"{System.IO.Path.GetTempFileName()}{info.Media[0].FileName}";
File.WriteAllBytes(filename, contentBytes);
var process = Process.Start(filename);
}
}
}
'The Base64 representation of the image will be printed in the console app window.
'http://messaging.cdyne.com/Messaging.svc?wsdl was added as Service Reference and given the name WSDL
Imports GetMedia.WSDL
Imports System.IO
Module Module1
Sub Main()
Dim client As WSDL.MessagingClient = New MessagingClient("mms2wsHttpBinding")
Dim resp As String = client.GetMedia(New Guid("f01d89fd-5155-5455-5585-e84ab8de8591"), 12441)
Dim imagetest = Convert.FromBase64String(resp)
File.WriteAllBytes("vbimage.jpg", imagetest)
Console.WriteLine("Image Saved")
Console.ReadLine()
End Sub
End Module
'Option to save the actual media. The media will automatically saved to the location you specified.
'http://messaging.cdyne.com/Messaging.svc?wsdl was added as Service Reference and given the name WSDL
Imports GetMedia.WSDL
Imports System.IO
Module Module1
Sub Main()
Dim path As String = "C:\Users\Desktop\image1.jpg"
Dim client As WSDL.MessagingClient = New MessagingClient("mms2wsHttpBinding")
Dim resp As String = client.GetMedia(New Guid("f01d89fd-5155-5455-5585-e84ab8de8591"), 001)
Dim imagetest = Convert.FromBase64String(resp)
File.WriteAllBytes(path, imagetest)
Console.WriteLine("Image Saved")
Console.ReadKey()
End Sub
End Module
'Option to display the actual media. The media will automatically display when running the code and the image will be saved to the location you specified.
'http://messaging.cdyne.com/Messaging.svc?wsdl was added as Service Reference and given the name WSDL
Imports GetMedia.WSDL
Imports System.IO
Module Module1
Sub Main()
Dim client As WSDL.MessagingClient = New WSDL.MessagingClient("mms2wsHttpBinding")
Dim info = client.GetMediaInfo(New WSDL.MediaCriteria() With {
.MediaId = 001,
.LicenseKey = New Guid("f01d89fd-5155-5455-5585-e84ab8de8591")
})
Dim content = client.GetMedia(New Guid("f01d89fd-5155-5455-5585-e84ab8de8591"), 001)
Dim contentBytes = Convert.FromBase64String(content)
Dim filename = $"{System.IO.Path.GetTempFileName()}{info.Media(0).FileName}"
File.WriteAllBytes(filename, contentBytes)
Dim process = System.Diagnostics.Process.Start(filename)
End Sub
End Module
//The Base64 representation of the image will be printed as the response.
<?php
$url='http://messaging.cdyne.com/Messaging.svc/GetMedia?LicenseKey=f01d89fd-5155-5455-5585-e84ab8de8591&MediaID=11777';
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_HTTPGET,true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Accept: application/json'));
$response = curl_exec($ch);
curl_close($ch);
print_r($response);
?>
//Option to return the actual media. The media will automatically saved to the location you specified.
<?php
$url='http://messaging.cdyne.com/Messaging.svc/GetMedia?LicenseKey=f01d89fd-5155-5455-5585-e84ab8de8591&MediaID=11777';
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_HTTPGET,true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Accept: application/json'));
$response = curl_exec($ch);
curl_close($ch);
$data = base64_decode($response);
$path = 'C:\Users\Desktop\TestImage.jpg';
file_put_contents($path, $data);
echo "Image Saved to: ", $path;
?>
//Option to display the actual media. The media will automatically display when running the code and the image will be saved to the location you specified.
<?php
$url='http://messaging.cdyne.com/Messaging.svc/GetMedia?LicenseKey=f01d89fd-5155-5455-5585-e84ab8de8591&MediaID=11777';
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_HTTPGET,true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Accept: application/json'));
$response = curl_exec($ch);
curl_close($ch);
$data = base64_decode($response);
$path = 'C:\Users\Desktop\TestImage.jpg';
file_put_contents($path, $data);
echo $data;
?>
Dim oXMLHTTP
Set oXMLHTTP = CreateObject("Microsoft.XMLHTTP")
Set oDoc = CreateObject("MSXML2.DOMDocument")
Call oXMLHttp.Open("GET", "http://messaging.cdyne.com/Messaging.svc/GetMedia?LicenseKey=f01d89fd-5155-5455-5585-e84ab8de8591&MediaId=1366", false)
Call oXMLHttp.setRequestHeader("Content-Type", "text/xml")
Call oXMLHttp.send
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.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
public final class GetMedia {
public static void main(String[] args) {
try {
URL url = new URL("http://messaging.cdyne.com/Messaging.svc/GetMedia?"
+ "LicenseKey=f01d89fd-5155-5455-5585-e84ab8de8591"
+ "&MediaID=11777");
try {
InputStream in = url.openStream();
StreamSource source = new StreamSource(in);
printResult(source);
} catch (java.io.IOException e) {
}
} catch (MalformedURLException e) {
}
}
private static void printResult(Source source) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
StreamResult sr = new StreamResult(bos);
Transformer trans = TransformerFactory.newInstance().newTransformer();
Properties oprops = new Properties();
oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
trans.setOutputProperties(oprops);
trans.transform(source, sr);
System.out.println("**** Response ******");
System.out.println(bos.toString());
bos.close();
System.out.println();
} catch (Exception e) {
}
}
}