This API is used to upsert (Update/insert) a single item/ title. If the item/title already exists it will overwrite the existing item or will insert as a new item.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
[ { "id": "Patriots_Day", "title": "Patriots Day", "type": "vod", "thumbnail": "https://images-na.ssl-images-amazon.com/images/M/MV5BODYxMDc0NTg2Nl5BMl5BanBnXkFtZTgwNjY0NDYzOTE@._V1_UX182_CR0,0,182,268_AL_.jpg", "subscriber_type": "free", "description": "A young woman finds herself in the basement of a man who says he's saved her life from a chemical attack that has left the outside uninhabitable.", "directors": "Dan Trachtenberg", "cast": "Elizabeth,Goodman, John Jr.", "pub_year": "2014", "duration": 103130, "cuepoints": "0,200" } ] |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<?xml version="1.0" encoding="UTF-8"?> <rss xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:media="http://search.yahoo.com/mrss/" version="2.0"> <channel guid="0" type="activity"> <title>Default</title> <link /> <description>desc</description> <item> <title>Patriots Day</title> <guid type="episodic" isPermaLink="false">Patriots_Day</guid> <description>Colonel Terry Lee, a pilot on a "no questions asked" airline, travels to the orient in search of a gold mine left to him by his grandfather.</description> <subscriber_type>registered</subscriber_type> <pub_date>1940-01-01</pub_date> <release_year>1940</release_year> <directors>James W. Horne</directors> <cast>William Tracy</cast> <cuepoints /> <media:thumbnail type="portrait-tv" url="https://images-na.ssl-images-amazon.com/images/M/MV5BODYxMDc0NTg2Nl5BMl5BanBnXkFtZTgwNjY0NDYzOTE@._V1_UX182_CR0,0,182,268_AL_.jpg" /> </item> </channel> </rss> |
NOTE : The above JSON and XML examples feed format are indicative. Format may vary based on the partner's existing feed format.
Example PHP Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
/** * Ingestion – Single Metadata * **/ // Example XML Data $xml_data = '<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml"> <channel> <title>CHANNEL TITLE</title> <description>CHANNEL DESCRIPTION</description> <pubDate>2016-08-31 11:40:20.0</pubDate> <item> <guid>XYZ123456</guid> <title>MOVIE TITLE</title> <media:thumbnail type="small" url="SMALL THUMBNAIL URL" /> <media:thumbnail type="large" url="LARGE THUMBNAIL URL" /> <media:content bit_rate="low-quality" url="LOW QUALITY MEDIA URL" filesize="15903581" type="video/quicktime" /> <media:content bit_rate="high-quality" url="HIGH QUALITY MEDIA URL" filesize="14326806" type="video/quicktime" /> </item> </channel> </rss>'; // Initialize post data $ch = curl_init("http://__JTV__HOST__/metax/3.0/ingest/XYZ123456"); // Here "XYZ123456" is "GUID" curl_setopt_array($ch, array( CURLOPT_CUSTOMREQUEST => "PUT", CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_POSTFIELDS => $xml_data, CURLOPT_HTTPHEADER => array( "Content-Type: application/xml", "Authorization: Bearer " . $token // Get token from "Getting Access Tokens" ) )); //execute $result = curl_exec($ch); // Check for errors if (!curl_errno($ch)) { $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); }else{ die(curl_error($ch)); } //close connection curl_close($ch); if(isset($httpcode) && $httpcode == 200){ echo $result; }else{ echo "HTTP Status Code ". $httpcode; } |
1 2 3 |
{ "status" : "success" } |
1 2 3 4 5 |
{ result: "error", message: "UNAUTHORIZED", reason: "No Authorization Token" } |
1 2 3 4 5 |
{ result: "error", message: "INVALID", reason: "Asset GUID not found.” } |
1 2 3 4 5 |
{ result: "error", message: "INVALID", reason: "Something went wrong. Please try again later.” } |
1 2 3 4 5 |
{ result: "error", message: "INVALID", reason: "Invalid tag” } |
1 2 3 4 5 |
{ result: "error", message: "INVALID", reason: "Invalid URL format" } |