Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8ce4ebb

Browse filesBrowse files
committed
Version 1.2
Added CA certificate failover and stopped NOTICE errors
1 parent 27d855f commit 8ce4ebb
Copy full SHA for 8ce4ebb

File tree

4 files changed

+86
-18
lines changed
Filter options

4 files changed

+86
-18
lines changed

‎LICENSE

Copy file name to clipboardExpand all lines: LICENSE
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2010 Zencoder
1+
Copyright (c) 2011 Zencoder
22

33
Permission is hereby granted, free of charge, to any person obtaining
44
a copy of this software and associated documentation files (the

‎README.markdown

Copy file name to clipboardExpand all lines: README.markdown
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Zencoder API PHP Library
22
==========================
33

4-
Author: [Steve Heffernan](http://www.steveheffernan.com) (steve (a) zencoder (.) com)
4+
Author: [Steve Heffernan](http://www.steveheffernan.com) (steve (a) zencoder (.) com)
55
Company: [Zencoder - Online Video Encoder](http://zencoder.com)
6-
Version: 1.1
7-
Date: 2010-06-04
8-
Repository: <http://github.com/zencoder/zencoder-php/>
6+
Version: 1.2
7+
Date: 2011-08-06
8+
Repository: <http://github.com/mchristopher/zencoder-php/>
99

1010
For more details on the Zencoder API requirements visit
1111
<http://zencoder.com/docs/api>
@@ -195,5 +195,6 @@ Your [notifications page](https://app.zencoder.com/notifications) will come in h
195195

196196
VERSIONS
197197
---------
198+
Version 1.2 - 2011-08-06 Added fixes for PHP Notices and SSL handling
198199
Version 1.1 - 2010-06-04 Added General API Requests
199200
Version 1.0 - 2010-04-02 Jobs and Notifications.

‎Zencoder.php

Copy file name to clipboardExpand all lines: Zencoder.php
+29-13Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,29 @@
22
/*
33
44
Zencoder API PHP Library
5-
Version: 1.0
5+
Version: 1.2
66
See the README file for info on how to use this library.
77
88
*/
99
define('ZENCODER_LIBRARY_NAME', "ZencoderPHP");
10-
define('ZENCODER_LIBRARY_VERSION', "1.0");
10+
define('ZENCODER_LIBRARY_VERSION', "1.2");
1111

1212
// Add JSON functions for PHP < 5.2.0
1313
if(!function_exists('json_encode')) {
14-
require_once('lib/JSON.php');
14+
require_once(dirname(__FILE__) . '/lib/JSON.php');
1515
$GLOBALS['JSON_OBJECT'] = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
1616
function json_encode($value) { return $GLOBALS['JSON_OBJECT']->encode($value); }
1717
function json_decode($value) { return $GLOBALS['JSON_OBJECT']->decode($value); }
1818
}
1919

20+
// Check that cURL extension is enabled
21+
if(!function_exists('curl_init')) {
22+
throw new Exception('You must have the cURL extension enabled to use this library.');
23+
}
24+
2025
class ZencoderJob {
2126

22-
var $new_job_url = "https://app.zencoder.com/api/jobs";
27+
var $new_job_url = "https://app.zencoder.com/api/v1/jobs";
2328
var $new_job_params = array();
2429
var $created = false;
2530
var $errors = array();
@@ -35,12 +40,12 @@ class ZencoderJob {
3540
function ZencoderJob($params, $options = array()) {
3641

3742
// Build using params if not sending request
38-
if($options["build"]) {
43+
if(!empty($options["build"])) {
3944
$this->update_attributes($params);
4045
return true;
4146
}
4247

43-
if($options["url"]) $this->new_job_url = $options["url"];
48+
if(!empty($options["url"])) $this->new_job_url = $options["url"];
4449
$this->new_job_params = $params;
4550
$this->created = $this->create();
4651
}
@@ -75,7 +80,7 @@ function update_attributes($attributes = array()) {
7580
// Use the Label for the key if avaiable.
7681
function create_outputs($outputs = array()) {
7782
foreach($outputs as $output_attrs) {
78-
if($output_attrs["label"]) {
83+
if(!empty($output_attrs["label"])) {
7984
$this->outputs[$output_attrs["label"]] = new ZencoderOutputFile($output_attrs);
8085
} else {
8186
$this->outputs[] = new ZencoderOutputFile($output_attrs);
@@ -172,10 +177,9 @@ class ZencoderCURL {
172177
CURLOPT_HEADER => 0, // Don't return the header in result
173178
CURLOPT_HTTPHEADER => array("Content-Type: application/json", "Accept: application/json"),
174179
CURLOPT_CONNECTTIMEOUT => 0, // Time in seconds to timeout send request. 0 is no timeout.
175-
// CURLOPT_FOLLOWLOCATION => 0, // Follow redirects. (stopped because it was causing an error in safe mode)
176-
// Dealing with the certificate. Still a sketchy area.
177-
CURLOPT_SSL_VERIFYPEER => 0, // Turn off verification, curl -k or --insecure
178-
CURLOPT_SSL_VERIFYHOST => 0
180+
CURLOPT_FOLLOWLOCATION => 1, // Follow redirects.
181+
CURLOPT_SSL_VERIFYPEER => 1,
182+
CURLOPT_SSL_VERIFYHOST => 1
179183
);
180184

181185
var $connected;
@@ -186,6 +190,11 @@ class ZencoderCURL {
186190
// Initialize
187191
function ZencoderCURL($url, $json, $options = array()) {
188192

193+
// If PHP in safe mode, disable following location
194+
if( ini_get('safe_mode') ) {
195+
$this->options[CURLOPT_FOLLOWLOCATION] = 0;
196+
}
197+
189198
// Add library details to request
190199
$this->options[CURLOPT_HTTPHEADER][] = "Zencoder-Library-Name: ".ZENCODER_LIBRARY_NAME;
191200
$this->options[CURLOPT_HTTPHEADER][] = "Zencoder-Library-Version: ".ZENCODER_LIBRARY_VERSION;
@@ -209,6 +218,13 @@ function ZencoderCURL($url, $json, $options = array()) {
209218

210219
// Execute session and store returned results
211220
$this->results = curl_exec($ch);
221+
222+
// Code based on Facebook PHP SDK
223+
// Retries request if unable to validate cert chain
224+
if (curl_errno($ch) == 60) { // CURLE_SSL_CACERT
225+
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/lib/zen_ca_chain.crt');
226+
$this->results = curl_exec($ch);
227+
}
212228

213229
// Store the HTTP status code given (201, 404, etc.)
214230
$this->status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
@@ -233,8 +249,8 @@ class ZencoderOutputNotification {
233249
var $job;
234250

235251
function ZencoderOutputNotification($params) {
236-
if($params["output"]) $this->output = new ZencoderOutputFile($params["output"]);
237-
if($params["job"]) $this->job = new ZencoderJob($params["job"], array("build" => true));
252+
if(!empty($params["output"])) $this->output = new ZencoderOutputFile($params["output"]);
253+
if(!empty($params["job"])) $this->job = new ZencoderJob($params["job"], array("build" => true));
238254
}
239255

240256
function catch_and_parse() {

‎lib/zen_ca_chain.crt

Copy file name to clipboard
+51Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIEIDCCAwigAwIBAgIQNE7VVyDV7exJ9C/ON9srbTANBgkqhkiG9w0BAQUFADCB
3+
qTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMf
4+
Q2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIw
5+
MDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxHzAdBgNV
6+
BAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwHhcNMDYxMTE3MDAwMDAwWhcNMzYw
7+
NzE2MjM1OTU5WjCBqTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5j
8+
LjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYG
9+
A1UECxMvKGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl
10+
IG9ubHkxHzAdBgNVBAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwggEiMA0GCSqG
11+
SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCsoPD7gFnUnMekz52hWXMJEEUMDSxuaPFs
12+
W0hoSVk3/AszGcJ3f8wQLZU0HObrTQmnHNK4yZc2AreJ1CRfBsDMRJSUjQJib+ta
13+
3RGNKJpchJ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wbR82LMgrsYiZwf5Eq0hRfNjyRGQq
47+
2HGn+xov+RmNNLIjv8RMVR2OROiqXZrdn/0Dx7okQ40tR0Tb9tiYyLL52u/tKVxp
48+
EvrRI5YPv5wN8nlFUzeaVi/oVxBw9u6JDEmJmsEj9cIqzEHPIqtlbreUgm0vQF9Y
49+
3uuVK6ZyaFIZkSqudZ1OkubK3lTqGKslPOZkpnkfJn1h7X3S5XFV2JMXfBQ4MDzf
50+
huNMrUnjl1nOG5srztxl1Asoa06ERlFE9zMILViXIa4=
51+
-----END CERTIFICATE-----

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.