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

getting warning when trying to update the metadata for a track

Open omer-sds opened this issue 8 years ago • 0 comments

hi i am trying to update the metadata for the track and i am getting a warning like below

Warning: array_key_exists() expects parameter 2 to be array, string given in sdcp/vendor/glenscott/soundcloud/src/Client.php on line 913

this line contains the code from thefunction _request which is below

if (array_key_exists(CURLOPT_POSTFIELDS, $options) && array_key_exists('track[asset_data]', $options[CURLOPT_POSTFIELDS])
        ) {

the second condition is the one where the warning occurs array_key_exists('track[asset_data]', $options[CURLOPT_POSTFIELDS]

though the description is updated to soundcloud track and i verified it , but it still gives me warning like above , i am providing the description with xml format and it is expecting it to be an array ? is that so ?

i am updating the track with the same code that is provided on the main page look below

//update metadata for the tracks 
$trackMetadata = <<<EOH
<track>
    <downloadable>true</downloadable>
    <description>This the description that is uploaded via local computer using the soundcloud API.</description>
</track>
EOH;

try {
    $metadataResponse = json_decode(
        $soundcloud->put(
            'tracks/145074846',
            $trackMetadata,
            array(CURLOPT_HTTPHEADER => array('Content-Type: application/xml'))
        ),
        true
    );
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
    exit($e->getMessage());
}
echo "<pre>";
print_r($metadataResponse);
exit;

omer-sds avatar Apr 01 '16 12:04 omer-sds