├── action.php
├── README
└── sample-form.html
/action.php:
--------------------------------------------------------------------------------
1 | ');
19 | $req->addChild('userid', MY_ID);
20 | $req->addChild('userkey', MY_KEY);
21 | $req->addChild('action', 'AddMedia');
22 | $req->addChild('source', $_POST['source']);
23 |
24 | $formatNode = $req->addChild('format');
25 | // Format fields
26 | foreach($_POST['format'] as $property => $value)
27 | {
28 | if ($value !== '')
29 | $formatNode->addChild($property, $value);
30 | }
31 |
32 | // Sending API request
33 | $res = sendRequest($req->asXML());
34 |
35 | try
36 | {
37 | // Creating new object from response XML
38 | $response = new SimpleXMLElement($res);
39 |
40 | // If there are any errors, set error message
41 | if(isset($response->errors[0]->error[0])) {
42 | $error = $response->errors[0]->error[0] . '';
43 | }
44 | else
45 | if ($response->message[0]) {
46 | // If message received, set OK message
47 | $message = $response->message[0] . '';
48 | }
49 | }
50 | catch(Exception $e)
51 | {
52 | // If wrong XML response received
53 | $error = $e->getMessage();
54 | }
55 |
56 | // Displaying error if any
57 | if (!empty($error)) {
58 | echo '
' . htmlspecialchars($error) . '
';
59 | }
60 |
61 | // Displaying message
62 | if (!empty($message)) {
63 | echo '' . htmlspecialchars($message) . '
';
64 | }
65 | exit;
66 | }
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | Encoding.com XML API Wrappers
2 | ==============
3 |
4 | This plugin connects to the Encoding.com API for pay as you go cloud based video transcoding services.
5 |
6 | Requires a API Key and User ID from Encoding.com. 30day adn 1GB free trial available at www.encoding.com/signup
7 |
8 | Examples:
9 |
10 | function sendRequest($xml)
11 | {
12 | $ch = curl_init();
13 | curl_setopt($ch, CURLOPT_URL, "http://manage.encoding.com/");
14 | curl_setopt($ch, CURLOPT_POSTFIELDS, "xml=" . urlencode($xml));
15 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
16 | curl_setopt($ch, CURLOPT_HEADER, 0);
17 | return curl_exec($ch);
18 | }
19 |
20 | // Begin processing User's POST
21 | if(!empty($_POST['source']))
22 | {
23 |
24 | /* examples of POST
25 | source='http://mylogin:mypassword@files.mybucket.s3.amazonaws.com/video/source/file_in.mov';
26 | format['output']='flv';
27 | format['size']='320x240';
28 | format['bitrate']='256k';
29 | format['audio_bitrate']='40k';
30 | format['destination']='http://mylogin:mypassword@files.mybucket.s3.amazonaws.com/video/dest/file_out.flv';
31 | */
32 | // Main fields
33 | $req = new SimpleXMLElement('');
34 | $req->addChild('userid', '777');
35 | $req->addChild('userkey', '277e0d0sdfaaa9140a27c03419f5era');
36 | $req->addChild('action', 'AddMedia');
37 | $req->addChild('source', $_POST['source']);
38 |
39 | $formatNode = $req->addChild('format');
40 | // Format fields
41 | foreach($_POST['format'] as $property => $value)
42 | {
43 | if ($value !== '')
44 | $formatNode->addChild($property, $value);
45 | }
46 |
47 | // Sending API request
48 | $res = sendRequest($req->asXML());
49 |
50 | try
51 | {
52 | // Creating new object from response XML
53 | $response = new SimpleXMLElement($res);
54 |
55 | // If there are any errors, set error message
56 | if(isset($response->errors[0]->error[0]))
57 | {
58 | $error = $response->errors[0]->error[0] . '';
59 | }
60 | else
61 | if ($response->message[0])
62 | {
63 | // If message received, set OK message
64 | $message = $response->message[0] . '';
65 | }
66 | }
67 | catch(Exception $e)
68 | {
69 | // If wrong XML response received
70 | $error = $e->getMessage();
71 | }
72 |
73 | // Displaying error if any
74 | if (!empty($error))
75 | {
76 | echo '' . htmlspecialchars($error) . '
';
77 | }
78 |
79 | // Displaying message
80 | if (!empty($message))
81 | {
82 | echo '' . htmlspecialchars($message) . '
';
83 | }
84 | exit;
85 | }
86 |
87 | Copyright (c) 2009 Encoding.com Inc.
--------------------------------------------------------------------------------
/sample-form.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Encoding.com Sample HTML Form
6 |
7 |
8 |
148 |
149 |
--------------------------------------------------------------------------------