This API is used to upsert (Update/insert) multiple item/ title at a time. If the item 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 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
[ { "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" }, . . . . { "id": "XXXXXXXXXX123", "title": "Monster Trucks", "type": "vod", "thumbnail": "https://s-media-cache-ak0.pinimg.com/736x/31/7c/4c/317c4c33477ae8e06cd6f3814900295e.jpg", "subscriber_type": "paid", "description": "Several rogue scientists attempt to reverse the effects of a deadly new Ice Age.", "rating": "nr", "directors": "Braunstein", "cast": "Fahey, Rhys-Davies, Malakul Lane", "pub_year": "2012", "duration": 5318820, "cuepoints": "0,1,404,832,1242,1979,2784,3402,4181,4622" } ] |
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 |
<?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> . . . . <item> <title>Monster Trucks</title> <guid type="vod" isPermaLink="false">CEG10010165</guid> <description>A disturbed boy who killed his dad is released from the asylum years later to find his mother has remarried, setting him off on a murderous rampage.</description> <subscriber_type>registered</subscriber_type> <duration>5153112</duration> <pub_date>2000-01-01</pub_date> <release_year>2000</release_year> <directors>Marc B. Ray</directors> <cast>Fred Holbert, Leigh Mitchell, Robert Knox</cast> <cuepoints>0,1,550,1210,1906,2415,2992,3569,4132</cuepoints> <media:rating scheme="urn:v-chip">r</media:rating> <media:thumbnail type="portrait-highres" url="https://s-media-cache-ak0.pinimg.com/736x/31/7c/4c/317c4c33477ae8e06cd6f3814900295e.jpg" /> </item> </channel> </rss> |
NOTE : The above JSON and XML examples request feed format 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 – Bulk 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/"); 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 6 7 8 9 10 11 12 13 14 15 16 17 18 |
{ "code": 0, "status": "partial-success", "items-results": [ { "result": "success", "message": "Successfully ingested" }, { "result": "error", "message": "Invalid input JSON", "reason": [ "title :: value is invalid/empty", "id :: value is invalid/empty" ] } ] } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
{ "code": 1, "status": "success", "items-results": [ { "result": "success", "message": "Successfully ingested" }, { "result": "success", "message": "Successfully ingested" } ] } |
1 2 3 4 5 |
{ result: "error", message: "UNAUTHORIZED", reason: "No Authorization Token" } |
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" } |
1 2 3 4 5 |
{ result: "error", message: "Bad Request", reason: "Invalid input JSON array/object" } |
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 |
{ "result": "error", "message": "Bad Request", "reason": { "code": -1, "status": "failure", "items-results": [ { "result": "error", "message": "Invalid input JSON", "reason": [ "title :: value is invalid/empty" ] }, { "result": "error", "message": "Invalid input JSON", "reason": [ "title :: value is invalid/empty", "id :: value is invalid/empty" ] } ] } } |