From 22d6409fd69b627a75c15174eb301c67444c4744 Mon Sep 17 00:00:00 2001 From: amzani Date: Mon, 28 Jul 2014 11:34:04 +0200 Subject: [PATCH 1/2] Added a CurlFile object that deprecates the old @filename syntax for PHP 5.5 --- Dailymotion.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Dailymotion.php b/Dailymotion.php index 575dc2e..94139bf 100644 --- a/Dailymotion.php +++ b/Dailymotion.php @@ -192,6 +192,26 @@ public function getAuthorizationUrl($display = 'page') 'display' => $display, ), null, '&'); } + /** + * Get the file path with the curl format + * + * PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax + * See: https://wiki.php.net/rfc/curl-file-upload + * + * @param $filePath String a path to the file to upload + * @return mixed The file curl path + */ + private function getCurlFile($filePath) + { + if (function_exists('curl_file_create')) + { + return curl_file_create($filePath); + } + else + { + return sprintf("@%s", $filePath); + } + } /** * Upload a file on the Dailymotion servers and generate an URL to be used with API methods. @@ -209,7 +229,7 @@ public function uploadFile($filePath, $force = '') } $timeout = $this->timeout; $this->timeout = null; - $result = json_decode($this->httpRequest($result['upload_url'], array('file' => '@' . $filePath)), true); + $result = json_decode($this->httpRequest($result['upload_url'], array('file' => $this->getCurlFile($filePath))), true); $this->timeout = $timeout; return $result['url']; } From 475c3079ed14d5fe369f929fbb56245d8f0bd6d2 Mon Sep 17 00:00:00 2001 From: Remiii Date: Wed, 27 Aug 2014 11:38:45 +0200 Subject: [PATCH 2/2] Typo bugfix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c235dbe..54dfd03 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Here is a usage example: setGrantType(Dailymotion::GRANT_TYPE_AUTHORIZATION, $apiKey, $apiSecret) + $api->setGrantType(Dailymotion::GRANT_TYPE_AUTHORIZATION, $apiKey, $apiSecret); try {