php-soundcloud icon indicating copy to clipboard operation
php-soundcloud copied to clipboard

cURL Deprecated error

Open sdvg opened this issue 11 years ago • 11 comments

I use PHP 5.5.3 and get the following deprecated-error after uploading a track:

Deprecated: curl_setopt_array(): The usage of the @filename API for file uploading is deprecated. Please use the CURLFile class instead in [...]

I use the example code from here: http://developers.soundcloud.com/docs#uploading

$track = json_decode($client->post('tracks', array(
    'track[title]' => $mytitle,
    'track[asset_data]' => '@' . $myfilepath
)));

sdvg avatar Feb 27 '14 17:02 sdvg

There's a branch named curl-file available including a patch for this. I've done some testing on 5.3.Z <= PHP <= 5.5.Z. Would you mind testing the patch as well?

mptre avatar Mar 02 '14 13:03 mptre

Thank you, I will test the branch within the week.

sdvg avatar Mar 04 '14 09:03 sdvg

Using the new branch I always get the following error:

Services_Soundcloud_Unsupported_Audio_Format_Exception: The given audio format is unsupported

My testfile is a valid mp3: mpthreetest.mp3: MPEG ADTS, layer III, v1, 128 kbps, 44.1 kHz, Monaural mime-type: audio/mpeg

Is my code from above still valid with the curl-file branch? I only removed the @-character from the file-path.

sdvg avatar Mar 09 '14 21:03 sdvg

Is this still the code you're using? Is $myfilepath an uploaded file reference?

$track = json_decode($client->post('tracks', array(
    'track[title]' => $mytitle,
    'track[asset_data]' => $myfilepath
)));

mptre avatar Mar 21 '14 10:03 mptre

Yes, $myfilepath is a string with the path to the uploaded file.

sdvg avatar Mar 21 '14 11:03 sdvg

Does the path include a file extension?

mptre avatar Mar 21 '14 11:03 mptre

can you please make this branch 'curl-file' available through composer

bobflay avatar Apr 21 '14 08:04 bobflay

That would be for me. I can take a look tonight and add it to my composer compatible fork.

internalsystemerror avatar Apr 22 '14 12:04 internalsystemerror

Hello!

My problem appeared when I switched to using this branch (because of the PHP 5.5 support).

What I'm basically doing in my project is uploading a track (works nicely with this branch) and adding the track to a Set (Playlist). This latter one stopped working (worked when I used the master branch) because in the updatePlaylist method the $postData array is getting transformed into a string, however after that the _request method still expects an array. My quick fix for this case was to add the followings to line 885:

&& is_array($options[CURLOPT_POSTFIELDS])

That solved my problem, however it might be possible it messed up something else.

Regards, Marton

csernikmarton avatar Jun 20 '14 13:06 csernikmarton

I'm also having an issue with getting "Undefined index: extension" using "Services_Soundcloud_File_Format::getMimeType()". The new class "Services_Soundcloud_File" is failing because the extension is not returned from the pathinfo() call using PHP's $_FILE['filename']['tmp_name'] value for the uploaded file. Might have to figure a way to pass the extension as a second parameter.

ghost avatar Nov 24 '14 22:11 ghost

Hi, I have submitted a pull request regarding some of these errors.

sebdesign avatar Dec 03 '14 03:12 sebdesign