From 49e895904c2b6641160e02f5b92697c41f47f154 Mon Sep 17 00:00:00 2001 From: Zac Shenker Date: Fri, 25 Jul 2014 10:58:16 +1000 Subject: [PATCH 01/15] Removing the Zencoder CA chain cert and updating README --- README.md | 11 +++++ Services/Zencoder.php | 3 +- Services/Zencoder/zencoder_ca_chain.crt | 62 ------------------------- 3 files changed, 12 insertions(+), 64 deletions(-) delete mode 100644 Services/Zencoder/zencoder_ca_chain.crt diff --git a/README.md b/README.md index 25a100b..6d8f470 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,17 @@ Zencoder API PHP Library ========================== +Author: [Zac Shenker] (zshenker (a) brightcove (.) com) +Company: [Brightcove/Zencoder](http://www.zencoder.com) +Version: 2.1.3 +Date: 2014-07-24 +Repository: + +The Zencoder CA chain certificate has been removed from the library as the bundled cert will be expiring on July 26 2014, +and should not be required as PHP/curl should be able to use the built in CA chain. +Please contact us at (help (a) zencoder (.) com) with an issues. + + Author: [Michael Christopher] (mchristopher (a) brightcove (.) com) Company: [Zencoder - Online Video Encoder](http://www.zencoder.com) Version: 2.1.1 diff --git a/Services/Zencoder.php b/Services/Zencoder.php index e5bf879..c458294 100644 --- a/Services/Zencoder.php +++ b/Services/Zencoder.php @@ -118,8 +118,7 @@ public function __construct( $this->http = new Services_Zencoder_Http( $api_host, array("curlopts" => array( - CURLOPT_USERAGENT => self::USER_AGENT, - CURLOPT_CAINFO => dirname(__FILE__) . "/Zencoder/zencoder_ca_chain.crt", + CURLOPT_USERAGENT => self::USER_AGENT ), "api_key" => $api_key, "debug" => $debug) ); $this->accounts = new Services_Zencoder_Accounts($this); diff --git a/Services/Zencoder/zencoder_ca_chain.crt b/Services/Zencoder/zencoder_ca_chain.crt deleted file mode 100644 index f064d81..0000000 --- a/Services/Zencoder/zencoder_ca_chain.crt +++ /dev/null @@ -1,62 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDJzCCApCgAwIBAgIBATANBgkqhkiG9w0BAQQFADCBzjELMAkGA1UEBhMCWk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2JhbCBSb290MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVD6C28FCc6HrH -iM3dFw4usJTQGz0O9pTAipTHBsiQl8i4ZBp6fmw8U+E3KHNgf7KXUwefU/ltWJTS -r41tiGeA5u2ylc9yMcqlHHK6XALnZELn+aks1joNrI1CqiQBOeacPwGFVw1Yh0X4 -04Wqk2kmhXBIgD8SFcd5tB8FLztimQIDAQABMA0GCSqGSIb3DQEBBAUAA4GBAG3r -GwnpXtlR22ciYaQqPEh346B8pt5zohQDhT37qw4wxYMWM4ETCJ57NE7fQMh017l9 -3PR2VX2bY1QY6fDq81yx2YtCHrnAlU66+tXifPVoYb+O7AWXX1uw16OFNMQkpw0P -lZPvy5TYnh+dXIVtx6quTx8itc2VrbqnzPmrC3p/ ------END CERTIFICATE----- From 2643a07f1147c18d94ff05b6f44095a4df68fad4 Mon Sep 17 00:00:00 2001 From: Zac Shenker Date: Fri, 25 Jul 2014 11:11:38 +1000 Subject: [PATCH 02/15] Fixing README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6d8f470..a2584e8 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Repository: The Zencoder CA chain certificate has been removed from the library as the bundled cert will be expiring on July 26 2014, and should not be required as PHP/curl should be able to use the built in CA chain. -Please contact us at (help (a) zencoder (.) com) with an issues. +Please contact us at help@zencoder.com with an issues. Author: [Michael Christopher] (mchristopher (a) brightcove (.) com) From 1cdc0dbeac3309ae593c4c8ee79b40650a33f828 Mon Sep 17 00:00:00 2001 From: Zac Shenker Date: Fri, 25 Jul 2014 11:35:26 +1000 Subject: [PATCH 03/15] Bumping version to 2.2.0 --- README.md | 2 +- Services/Zencoder.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a2584e8..5846df7 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Zencoder API PHP Library Author: [Zac Shenker] (zshenker (a) brightcove (.) com) Company: [Brightcove/Zencoder](http://www.zencoder.com) -Version: 2.1.3 +Version: 2.2.0 Date: 2014-07-24 Repository: diff --git a/Services/Zencoder.php b/Services/Zencoder.php index c458294..6d453d7 100644 --- a/Services/Zencoder.php +++ b/Services/Zencoder.php @@ -5,7 +5,7 @@ * @category Services * @package Services_Zencoder * @author Michael Christopher - * @version Release: 2.1.2 + * @version Release: 2.2.0 * @license http://creativecommons.org/licenses/MIT/MIT * @link http://github.com/zencoder/zencoder-php * @access private @@ -26,14 +26,14 @@ function Services_Zencoder_autoload($className) * @category Services * @package Services_Zencoder * @author Michael Christopher - * @version Release: 2.1.2 + * @version Release: 2.2.0 * @license http://creativecommons.org/licenses/MIT/MIT * @link http://github.com/zencoder/zencoder-php */ class Services_Zencoder extends Services_Zencoder_Base { - const USER_AGENT = 'ZencoderPHP v2.1.2'; + const USER_AGENT = 'ZencoderPHP v2.2.0'; /** * Contains the HTTP communication class From 4607c612ecd87c4249202d2d21358d0d99e17162 Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Mon, 28 Jul 2014 19:10:50 -0500 Subject: [PATCH 04/15] Update README.md for formatting --- README.md | 205 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 119 insertions(+), 86 deletions(-) diff --git a/README.md b/README.md index 5846df7..3a010a1 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,13 @@ Zencoder API PHP Library ========================== Author: [Zac Shenker] (zshenker (a) brightcove (.) com) + Company: [Brightcove/Zencoder](http://www.zencoder.com) + Version: 2.2.0 + Date: 2014-07-24 + Repository: The Zencoder CA chain certificate has been removed from the library as the bundled cert will be expiring on July 26 2014, @@ -13,9 +17,13 @@ Please contact us at help@zencoder.com with an issues. Author: [Michael Christopher] (mchristopher (a) brightcove (.) com) + Company: [Zencoder - Online Video Encoder](http://www.zencoder.com) + Version: 2.1.1 + Date: 2012-08-02 + Repository: Parts of this library are based on @@ -29,18 +37,22 @@ For more details on the Zencoder API requirements visit To start working with the library, create a new instance of the Services_Zencoder class, passing your API Key as the 1st parameter. - $zencoder = new Services_Zencoder('93h630j1dsyshjef620qlkavnmzui3'); +```php +$zencoder = new Services_Zencoder('93h630j1dsyshjef620qlkavnmzui3'); +``` Once you have created the object, you can use it to interact with the API. For full information, see the Documentation folder, but here is a quick overview of some of the functions that can be called: - $zencoder->accounts->create($array); - $zencoder->jobs->create($array); - $zencoder->jobs->progress($job_id); - $zencoder->inputs->details($input_id); - $zencoder->outputs->details($output_id); - $zencoder->notifications->parseIncoming(); +```php +$zencoder->accounts->create($array); +$zencoder->jobs->create($array); +$zencoder->jobs->progress($job_id); +$zencoder->inputs->details($input_id); +$zencoder->outputs->details($output_id); +$zencoder->notifications->parseIncoming(); +``` Any errors will throw a Services_Zencoder_Exception. You can call getErrors() on an exception and it will return any errors received from the Zencoder API. @@ -48,119 +60,134 @@ and it will return any errors received from the Zencoder API. ENCODING JOB ------------ + The ZencoderJob object creates an encoding job using [cURL](http://zencoder.com/docs/glossary/curl/) to send [JSON](http://zencoder.com/docs/glossary/json/) formatted parameters to Zencoder's encoding API. ### Step 1 + Visit the [API builder](https://app.zencoder.com/api_builder) in your account, and execute a successful encoding job. ### Step 2 + Copy the successful JSON string, starting with the first curly brace "{", and pass it as the parameters for a new ZencoderJob object. Execute the script on your server to test that it works. #### Example -
-    jobs->create(
+  // New Encoding Job
+  $encoding_job = $zencoder->jobs->create(
+    array(
+      "input" => "s3://bucket-name/file-name.avi",
+      "outputs" => array(
         array(
-          "input" => "s3://bucket-name/file-name.avi",
-          "outputs" => array(
-            array(
-              "label" => "web"
-            )
-          )
+          "label" => "web"
         )
-      );
-
-      // Success if we got here
-      echo "w00t! \n\n";
-      echo "Job ID: ".$encoding_job->id."\n";
-      echo "Output ID: ".$encoding_job->outputs['web']->id."\n";
-      // Store Job/Output IDs to update their status when notified or to check their progress.
-    } catch (Services_Zencoder_Exception $e) {
-      // If were here, an error occured
-      echo "Fail :(\n\n";
-      echo "Errors:\n";
-      foreach ($e->getErrors() as $error) echo $error."\n";
-      echo "Full exception dump:\n\n";
-      print_r($e);
-    }
-
-    echo "\nAll Job Attributes:\n";
-    var_dump($encoding_job);
-
-    ?>
-    
+ ) + ) + ); + + // Success if we got here + echo "w00t! \n\n"; + echo "Job ID: ".$encoding_job->id."\n"; + echo "Output ID: ".$encoding_job->outputs['web']->id."\n"; + // Store Job/Output IDs to update their status when notified or to check their progress. +} catch (Services_Zencoder_Exception $e) { + // If were here, an error occured + echo "Fail :(\n\n"; + echo "Errors:\n"; + foreach ($e->getErrors() as $error) echo $error."\n"; + echo "Full exception dump:\n\n"; + print_r($e); +} + +echo "\nAll Job Attributes:\n"; +var_dump($encoding_job); + +?> +``` ### Step 3 + Modify the above script to meet your needs. + Your [API Request History](https://app.zencoder.com/api_requests) may come in handy. + You can revisit your [API builder](https://app.zencoder.com/api_builder) to add/update parameters of the JSON. You can translate the JSON string into nested associative arrays so that you can dynamically change attributes like "input". The previous JSON example would become: - $encoding_job = $zencoder->jobs->create(array( - "input" => "s3://bucket-name/file-name.avi", - "outputs" => array( - array( - "label" => "web" - ) - ) - )); +```php +$encoding_job = $zencoder->jobs->create(array( + "input" => "s3://bucket-name/file-name.avi", + "outputs" => array( + array( + "label" => "web" + ) + ) +)); +``` NOTIFICATION HANDLING ---------------------- + The ZencoderOutputNotification class is used to capture and parse JSON data sent from Zencoder to your app when an output file has been completed. ### Step 1 + Create a script to receive notifications, and upload it to a location on your server that is publicly accessible. #### Example - notifications->parseIncoming(); +// Catch notification +$notification = $zencoder->notifications->parseIncoming(); - // Check output/job state - if($notification->job->outputs[0]->state == "finished") { - echo "w00t!\n"; +// Check output/job state +if($notification->job->outputs[0]->state == "finished") { + echo "w00t!\n"; - // If you're encoding to multiple outputs and only care when all of the outputs are finished - // you can check if the entire job is finished. - if($notification->job->state == "finished") { - echo "Dubble w00t!"; - } - } elseif ($notification->job->outputs[0]->state == "cancelled") { - echo "Cancelled!\n"; - } else { - echo "Fail!\n"; - echo $notification->job->outputs[0]->error_message."\n"; - echo $notification->job->outputs[0]->error_link; - } + // If you're encoding to multiple outputs and only care when all of the outputs are finished + // you can check if the entire job is finished. + if($notification->job->state == "finished") { + echo "Dubble w00t!"; + } +} elseif ($notification->job->outputs[0]->state == "cancelled") { + echo "Cancelled!\n"; +} else { + echo "Fail!\n"; + echo $notification->job->outputs[0]->error_message."\n"; + echo $notification->job->outputs[0]->error_link; +} - ?> +?> +``` ### Step 2 + In the parameters for an encoding job, add the URL for your script to the notifications array of each output you want to be notified for. Then submit the job to test if it works. @@ -168,26 +195,32 @@ Then submit the job to test if it works. #### Example - ... - "outputs" => array( - array( - "label" => "web", - "notifications" => array("http://example.com.com/encoding/notification.php") - ), - array( - "label" => "iPhone", - "notifications" => array("http://example.com.com/encoding/notification.php") - ) - ) - ... +```php +... +"outputs" => array( + array( + "label" => "web", + "notifications" => array("http://example.com.com/encoding/notification.php") + ), + array( + "label" => "iPhone", + "notifications" => array("http://example.com.com/encoding/notification.php") + ) +) +... +``` ### Step 3 + Modify the above script to meet your needs. + Your [notifications page](https://app.zencoder.com/notifications) will come in handy. VERSIONS --------- + + Version 2.2.0 - 2014-07-24 Removing the bundled CA chain to address expiring intermediate certificate Version 2.1.1 - 2012-08-02 Fixing issue where jobs index call didn't return jobs as individual objects Version 2.1.0 - 2012-06-05 Adding support for job-level notifications & merging output with job in notification object Version 2.0.2 - 2012-01-11 Fixed job creation response object, added documentation to variables From e03988cb0acac15c17769d882b89245430662985 Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Mon, 28 Jul 2014 19:32:21 -0500 Subject: [PATCH 05/15] Make it so that you can set curl opts for CA paths and files --- Services/Zencoder.php | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/Services/Zencoder.php b/Services/Zencoder.php index 6d453d7..d11a182 100644 --- a/Services/Zencoder.php +++ b/Services/Zencoder.php @@ -96,12 +96,16 @@ class Services_Zencoder extends Services_Zencoder_Base * @param string $api_version API version * @param string $api_host API host * @param bool $debug Enable debug mode + * @param string $ca_path Path to a directory that holds multiple CA certificates + * @param string $ca_file Path to a file holding one or more certificates to verify the peer with */ public function __construct( $api_key = NULL, $api_version = 'v2', $api_host = 'https://app.zencoder.com', - $debug = false + $debug = false, + $ca_path = NULL, + $ca_file = NULL ) { // Check that library dependencies are met @@ -114,13 +118,18 @@ public function __construct( if (!function_exists('curl_init')) { throw new Services_Zencoder_Exception('cURL extension must be enabled.'); } + $this->version = $api_version; - $this->http = new Services_Zencoder_Http( - $api_host, - array("curlopts" => array( - CURLOPT_USERAGENT => self::USER_AGENT - ), "api_key" => $api_key, "debug" => $debug) - ); + + $http_options = array("api_version" => $api_key, "debug" => $debug, "curlopts" => array(CURLOPT_USERAGENT => self::USER_AGENT)); + if (isset($ca_path)) { + $http_options["curlopts"][CURLOPT_CAPATH] = realpath($ca_path); + } + if (isset($ca_file)) { + $http_options["curlopts"][CURLOPT_CAINFO] = realpath($ca_file); + } + + $this->http = new Services_Zencoder_Http($api_host, $http_options); $this->accounts = new Services_Zencoder_Accounts($this); $this->inputs = new Services_Zencoder_Inputs($this); $this->jobs = new Services_Zencoder_Jobs($this); From 7673c4b2f3635e9b1999be16d309722ab01c2e48 Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Tue, 29 Jul 2014 14:44:33 -0500 Subject: [PATCH 06/15] Bump version to 2.2.1 and add docs --- README.md | 22 ++++++++++++++++++++++ Services/Zencoder.php | 6 +++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3a010a1..152362d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,27 @@ Zencoder API PHP Library ========================== +Author: [Nathan Sutton] (nsutton (a) brightcove (.) com) + +Company: [Brightcove/Zencoder](http://www.zencoder.com) + +Version: 0.2.1 + +Date: 2014-07-29 + +Repository: + +To help address problems where users cannot modify php.ini to point cURL to their system CA bundle path, or are using a PHP release before 5.3.7, we have extended this library to allow users to set CURLOPT\_CAPATH and CURLOPT\_CAINFO on the cURL connection used to submit requests. + +```php +$zencoder = new Services_Zencoder($my_api_key, 'v2', 'https://app.zencoder.com', false, $my_curlopt_capath, $my_curlopt_cainfo); +``` + +See also the constructor for `Services_Zencoder` for more information on the available arguments. + +See [the cURL CA bundle extraction page](http://curl.haxx.se/docs/caextract.html) for information on obtaining a CA bundle. We recommend using the HTTPS link to download the CA bundle. + + Author: [Zac Shenker] (zshenker (a) brightcove (.) com) Company: [Brightcove/Zencoder](http://www.zencoder.com) @@ -220,6 +241,7 @@ Your [notifications page](https://app.zencoder.com/notifications) will come in h VERSIONS --------- + Version 2.2.1 - 2014-07-29 Surrport setting CURLOPT_CAPATH and CURLOPT_CAINFO on cURL connections. Version 2.2.0 - 2014-07-24 Removing the bundled CA chain to address expiring intermediate certificate Version 2.1.1 - 2012-08-02 Fixing issue where jobs index call didn't return jobs as individual objects Version 2.1.0 - 2012-06-05 Adding support for job-level notifications & merging output with job in notification object diff --git a/Services/Zencoder.php b/Services/Zencoder.php index d11a182..671380a 100644 --- a/Services/Zencoder.php +++ b/Services/Zencoder.php @@ -5,7 +5,7 @@ * @category Services * @package Services_Zencoder * @author Michael Christopher - * @version Release: 2.2.0 + * @version Release: 2.2.1 * @license http://creativecommons.org/licenses/MIT/MIT * @link http://github.com/zencoder/zencoder-php * @access private @@ -26,14 +26,14 @@ function Services_Zencoder_autoload($className) * @category Services * @package Services_Zencoder * @author Michael Christopher - * @version Release: 2.2.0 + * @version Release: 2.2.1 * @license http://creativecommons.org/licenses/MIT/MIT * @link http://github.com/zencoder/zencoder-php */ class Services_Zencoder extends Services_Zencoder_Base { - const USER_AGENT = 'ZencoderPHP v2.2.0'; + const USER_AGENT = 'ZencoderPHP v2.2.1'; /** * Contains the HTTP communication class From b3046f21747f7f5699da08cf66e8a488271760c8 Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Tue, 29 Jul 2014 17:40:11 -0500 Subject: [PATCH 07/15] Fixing a bug where api_key was set as api_version in the http connection options --- Services/Zencoder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Services/Zencoder.php b/Services/Zencoder.php index 671380a..be1cd0a 100644 --- a/Services/Zencoder.php +++ b/Services/Zencoder.php @@ -121,7 +121,7 @@ public function __construct( $this->version = $api_version; - $http_options = array("api_version" => $api_key, "debug" => $debug, "curlopts" => array(CURLOPT_USERAGENT => self::USER_AGENT)); + $http_options = array("api_key" => $api_key, "debug" => $debug, "curlopts" => array(CURLOPT_USERAGENT => self::USER_AGENT)); if (isset($ca_path)) { $http_options["curlopts"][CURLOPT_CAPATH] = realpath($ca_path); } From f50a04534053bac0ea40b84c30f6c7760d29eddf Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Tue, 29 Jul 2014 17:41:33 -0500 Subject: [PATCH 08/15] Documenting the changes in 2.2.2 --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 152362d..b6bf454 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Author: [Nathan Sutton] (nsutton (a) brightcove (.) com) Company: [Brightcove/Zencoder](http://www.zencoder.com) -Version: 0.2.1 +Version: 2.2.2 Date: 2014-07-29 @@ -241,7 +241,8 @@ Your [notifications page](https://app.zencoder.com/notifications) will come in h VERSIONS --------- - Version 2.2.1 - 2014-07-29 Surrport setting CURLOPT_CAPATH and CURLOPT_CAINFO on cURL connections. + Version 2.2.2 - 2014-07-29 Fixed a bug where api_key was set as api_version in the http connection options + Version 2.2.1 - 2014-07-29 Support setting CURLOPT_CAPATH and CURLOPT_CAINFO on cURL connections. Version 2.2.0 - 2014-07-24 Removing the bundled CA chain to address expiring intermediate certificate Version 2.1.1 - 2012-08-02 Fixing issue where jobs index call didn't return jobs as individual objects Version 2.1.0 - 2012-06-05 Adding support for job-level notifications & merging output with job in notification object From e2604c441163c36fd27097d8d9a22fcdf16d1ee4 Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Tue, 29 Jul 2014 17:43:19 -0500 Subject: [PATCH 09/15] Fixed the versions listed in the user agent and throughout the code --- README.md | 3 ++- Services/Zencoder.php | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b6bf454..c002732 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Author: [Nathan Sutton] (nsutton (a) brightcove (.) com) Company: [Brightcove/Zencoder](http://www.zencoder.com) -Version: 2.2.2 +Version: 2.2.3 Date: 2014-07-29 @@ -241,6 +241,7 @@ Your [notifications page](https://app.zencoder.com/notifications) will come in h VERSIONS --------- + Version 2.2.3 - 2014-07-29 Fixed the versions listed in the user agent and throughout the code Version 2.2.2 - 2014-07-29 Fixed a bug where api_key was set as api_version in the http connection options Version 2.2.1 - 2014-07-29 Support setting CURLOPT_CAPATH and CURLOPT_CAINFO on cURL connections. Version 2.2.0 - 2014-07-24 Removing the bundled CA chain to address expiring intermediate certificate diff --git a/Services/Zencoder.php b/Services/Zencoder.php index be1cd0a..ba8e209 100644 --- a/Services/Zencoder.php +++ b/Services/Zencoder.php @@ -5,7 +5,7 @@ * @category Services * @package Services_Zencoder * @author Michael Christopher - * @version Release: 2.2.1 + * @version Release: 2.2.3 * @license http://creativecommons.org/licenses/MIT/MIT * @link http://github.com/zencoder/zencoder-php * @access private @@ -26,14 +26,14 @@ function Services_Zencoder_autoload($className) * @category Services * @package Services_Zencoder * @author Michael Christopher - * @version Release: 2.2.1 + * @version Release: 2.2.3 * @license http://creativecommons.org/licenses/MIT/MIT * @link http://github.com/zencoder/zencoder-php */ class Services_Zencoder extends Services_Zencoder_Base { - const USER_AGENT = 'ZencoderPHP v2.2.1'; + const USER_AGENT = 'ZencoderPHP v2.2.3'; /** * Contains the HTTP communication class From a945431352da25357dc3f82b0dc13625a142d2e1 Mon Sep 17 00:00:00 2001 From: Chris Warren Date: Tue, 27 Feb 2018 11:42:33 -0600 Subject: [PATCH 10/15] Change docs URL to new site --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c002732..1c82fd4 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ For more details on v2 of the Zencoder API visit For more details on the Zencoder API requirements visit - + To start working with the library, create a new instance of the Services_Zencoder class, passing your API Key as the 1st parameter. @@ -82,8 +82,8 @@ and it will return any errors received from the Zencoder API. ENCODING JOB ------------ -The ZencoderJob object creates an encoding job using [cURL](http://zencoder.com/docs/glossary/curl/) -to send [JSON](http://zencoder.com/docs/glossary/json/) formatted parameters to Zencoder's encoding API. +The ZencoderJob object creates an encoding job using cURL +to send JSON formatted parameters to Zencoder's encoding API. ### Step 1 From 0360517e9a87c5fc1437521bd8762d22b87fd687 Mon Sep 17 00:00:00 2001 From: Jason Cooke Date: Wed, 21 Aug 2019 10:38:10 +1200 Subject: [PATCH 11/15] docs: fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1c82fd4..03ec790 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ try { echo "Output ID: ".$encoding_job->outputs['web']->id."\n"; // Store Job/Output IDs to update their status when notified or to check their progress. } catch (Services_Zencoder_Exception $e) { - // If were here, an error occured + // If were here, an error occurred echo "Fail :(\n\n"; echo "Errors:\n"; foreach ($e->getErrors() as $error) echo $error."\n"; From 557313a840de116df5f0ad8823f9a3686d3c29a4 Mon Sep 17 00:00:00 2001 From: Mike Christopher Date: Thu, 5 Sep 2019 10:59:59 -0700 Subject: [PATCH 12/15] Updating HTTP header parsing --- Services/Zencoder.php | 4 ++-- Services/Zencoder/Http.php | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Services/Zencoder.php b/Services/Zencoder.php index ba8e209..8886970 100644 --- a/Services/Zencoder.php +++ b/Services/Zencoder.php @@ -231,10 +231,10 @@ private function _processResponse($response) if ( $status == 204 || (($status == 200 || $status == 201) && trim($body) == "")) { return TRUE; } - if (empty($headers['Content-Type'])) { + if (empty($headers['content-type'])) { throw new Services_Zencoder_Exception('Response header is missing Content-Type', $body); } - switch ($headers['Content-Type']) { + switch ($headers['content-type']) { case 'application/json': case 'application/json; charset=utf-8': return $this->_processJsonResponse($status, $headers, $body); diff --git a/Services/Zencoder/Http.php b/Services/Zencoder/Http.php index eed8c7d..0a27a95 100644 --- a/Services/Zencoder/Http.php +++ b/Services/Zencoder/Http.php @@ -115,7 +115,8 @@ public function __call($name, $args) { array_shift($header_lines); foreach ($header_lines as $line) { list($key, $value) = explode(":", $line, 2); - $headers[$key] = trim($value); + // Ensure headers are lowercase per https://tools.ietf.org/html/rfc2616#section-4.2 + $headers[strtolower($key)] = trim($value); } curl_close($curl); if (isset($buf) && is_resource($buf)) fclose($buf); From 7e843bbcd18ab8d50ef6134122483d78700a77d7 Mon Sep 17 00:00:00 2001 From: Justin Greer Date: Thu, 5 Sep 2019 13:36:35 -0500 Subject: [PATCH 13/15] composer: use https urls --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 32bfcb8..c8fcfdd 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "zencoder/zencoder-php", - "homepage": "http://github.com/zencoder/zencoder-php", + "homepage": "https://github.com/zencoder/zencoder-php", "description":"Zencoder integration library for PHP", "keywords":["zencoder", "encoding", "encoder", "cloud"], "type":"library", @@ -16,7 +16,7 @@ "authors":[ { "name":"Zencoder", - "homepage":"http://zencoder.com" + "homepage":"https://zencoder.com" } ] } From f1617a7f89a7422dd8682c276dd644764c4200f8 Mon Sep 17 00:00:00 2001 From: Justin Greer Date: Thu, 5 Sep 2019 13:44:06 -0500 Subject: [PATCH 14/15] Bump version to 2.2.4 --- README.md | 11 +++++++++++ Services/Zencoder.php | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 03ec790..13f0f96 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,17 @@ Zencoder API PHP Library ========================== +Company: [Brightcove/Zencoder](http://www.zencoder.com) + +Version: 2.2.4 + +Date: 2019-09-05 + +Repository: + +HTTP headers are handled in a case-insensitve manner so that they are compatible with HTTP2. + + Author: [Nathan Sutton] (nsutton (a) brightcove (.) com) Company: [Brightcove/Zencoder](http://www.zencoder.com) diff --git a/Services/Zencoder.php b/Services/Zencoder.php index 8886970..6e8447c 100644 --- a/Services/Zencoder.php +++ b/Services/Zencoder.php @@ -5,7 +5,7 @@ * @category Services * @package Services_Zencoder * @author Michael Christopher - * @version Release: 2.2.3 + * @version Release: 2.2.4 * @license http://creativecommons.org/licenses/MIT/MIT * @link http://github.com/zencoder/zencoder-php * @access private @@ -26,14 +26,14 @@ function Services_Zencoder_autoload($className) * @category Services * @package Services_Zencoder * @author Michael Christopher - * @version Release: 2.2.3 + * @version Release: 2.2.4 * @license http://creativecommons.org/licenses/MIT/MIT * @link http://github.com/zencoder/zencoder-php */ class Services_Zencoder extends Services_Zencoder_Base { - const USER_AGENT = 'ZencoderPHP v2.2.3'; + const USER_AGENT = 'ZencoderPHP v2.2.4'; /** * Contains the HTTP communication class From ae8ddf9711431f48b2676c3ae4e7342e7bd867ca Mon Sep 17 00:00:00 2001 From: Justin Greer Date: Mon, 9 Sep 2019 13:34:59 -0500 Subject: [PATCH 15/15] Update versions list at bottom of README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 13f0f96..eaba01f 100644 --- a/README.md +++ b/README.md @@ -252,6 +252,7 @@ Your [notifications page](https://app.zencoder.com/notifications) will come in h VERSIONS --------- + Version 2.2.4 - 2019-09-05 HTTP headers are handled in a case-insensitve manner so that they are compatible with HTTP2. Version 2.2.3 - 2014-07-29 Fixed the versions listed in the user agent and throughout the code Version 2.2.2 - 2014-07-29 Fixed a bug where api_key was set as api_version in the http connection options Version 2.2.1 - 2014-07-29 Support setting CURLOPT_CAPATH and CURLOPT_CAINFO on cURL connections.