BrightcoveOS / PHP-MAPI-Wrapper

This project provides a starting point for integrating the Brightcove Media API into your application. It provides simple ways to interact with the API, as well as a long list of helper functions.
http://opensource.brightcove.com/project/PHP-MAPI-Wrapper/
48 stars 51 forks source link

exception 'ErrorException' with message 'curl_setopt(): The usage of the @filename API for file uploading is deprecated. Please use the CURLFile class instead' #32

Open rowp opened 10 years ago

rowp commented 10 years ago

Since upgrade to PHP 5.5 there are some depreciated CURL functions.

Exception 'ErrorException' with message 'curl_setopt(): The usage of the @filename API for file uploading is deprecated. Please use the CURLFile class instead'

Is there a fix?

batcholi commented 9 years ago

I have a very simple fix that does the job, feel free to improve it. BCMAPI.php on Line ~ 1350, curlRequest method :

    private function curlRequest($request, $get_request = FALSE)
    {
        $curl = curl_init();

        if($get_request)
        {
            curl_setopt($curl, CURLOPT_URL, $request);
        } else {
            curl_setopt($curl, CURLOPT_URL, $this->getUrl('write'));
            curl_setopt($curl, CURLOPT_POST, 1);

+           if (!empty($request['file'])) {
+             $file = substr($request['file'], 1);
+             $request['file'] = new CURLFile($file);
+           }

            curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
        }

        // ...

    }