php-soundcloud
php-soundcloud copied to clipboard
cURL Deprecated error
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
)));
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?
Thank you, I will test the branch within the week.
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.
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
)));
Yes, $myfilepath is a string with the path to the uploaded file.
Does the path include a file extension?
can you please make this branch 'curl-file' available through composer
That would be for me. I can take a look tonight and add it to my composer compatible fork.
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
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.
Hi, I have submitted a pull request regarding some of these errors.