any examples available using the PHP file_get_contents function to call the files/list_folder api?
( I am able to use curl from PHP to call the dropbox apis. But my code fails on one PHP server but works on another. Would like to see if file_get_contents will work. )
Here is my code. There error I am getting is "failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request "
function listFolder( $token )
{
$text = "{\"path\": \"\",\"recursive\": false,\"include_media_info\": false,\"include_deleted\": false,\"include_has_explicit_shared_members\": false,\"include_mounted_folders\": true}" ;
echo $text . '<br>' ;
$postdata = http_build_query(
array(
'data' => $text)) ;
$opts = array(
'http' => array(
'method' => 'POST',
'header' => array('Authorization: Bearer ' . $token,
'Content-Type: application/json'),
'content' => $postdata),
'ssl' => array(
"verify_peer"=>false,
"verify_peer_name"=>false)
);
$context = stream_context_create($opts);
$result = file_get_contents('https://api.dropboxapi.com/2/files/list_folder', false, $context);
}