@@ -57,6 +57,16 @@ public function __construct(
57
57
$ api_version = 'v2 ' ,
58
58
$ api_host = 'https://app.zencoder.com '
59
59
) {
60
+ // Check that library dependencies are met
61
+ if (strnatcmp (phpversion (),'5.2.0 ' ) < 0 ) {
62
+ throw new Services_Zencoder_Exception ('PHP version 5.2 or higher is required. ' );
63
+ }
64
+ if (!function_exists ('json_encode ' )) {
65
+ throw new Services_Zencoder_Exception ('JSON support must be enabled. ' );
66
+ }
67
+ if (!function_exists ('curl_init ' )) {
68
+ throw new Services_Zencoder_Exception ('cURL extension must be enabled. ' );
69
+ }
60
70
$ this ->version = $ api_version ;
61
71
$ this ->http = new Services_Zencoder_Http (
62
72
$ api_host ,
@@ -120,7 +130,7 @@ public function createData($path, $body = "", array $opts = array())
120
130
? $ this ->_processResponse ($ this ->http ->post ($ this ->_getApiPath ($ opts ) . $ path , $ headers ))
121
131
: $ this ->_processResponse (
122
132
$ this ->http ->post (
123
- $ path ,
133
+ $ this -> _getApiPath ( $ opts ) . $ path ,
124
134
$ headers ,
125
135
$ body
126
136
)
@@ -143,7 +153,7 @@ public function updateData($path, $body = "", array $opts = array())
143
153
? $ this ->_processResponse ($ this ->http ->put ($ this ->_getApiPath ($ opts ) . $ path , $ headers ))
144
154
: $ this ->_processResponse (
145
155
$ this ->http ->put (
146
- $ path ,
156
+ $ this -> _getApiPath ( $ opts ) . $ path ,
147
157
$ headers ,
148
158
$ body
149
159
)
@@ -187,10 +197,8 @@ private function _processJsonResponse($status, $headers, $body) {
187
197
return $ decoded ;
188
198
}
189
199
throw new Services_Zencoder_Exception (
190
- (int )$ decoded ->status ,
191
- $ decoded ->message ,
192
- isset ($ decoded ->code ) ? $ decoded ->code : null ,
193
- isset ($ decoded ->more_info ) ? $ decoded ->more_info : null
200
+ "Invalid HTTP status code: " . $ status
201
+ . ", body: " . $ body
194
202
);
195
203
}
196
204
}
0 commit comments