menu

Saturday 10 February 2018

how to get all share link of dropbox folder

Dropbox

Request and response formats

In general, the Dropbox API uses HTTP POST requests with JSON arguments and JSON responses. Request authentication is via OAuth 2.0 using the Authorization request header or authorization URL parameter.


/*// Step 1. For Call HTTP Autherization .
https://www.dropbox.com/oauth2/authorize?client_id=XXXXXXXXX&response_type=token&state=ahometech&require_role=personal&disable_signup=false&force_reauthentication=false&redirect_uri=http://localhost/mydropbox/xyz.php

After that you will get this responce
http://localhost/mydropbox/list.php#access_token=wGRn6y-Q5kAAAAAAAAAAKB3okg7UNewre-UAjwPOu2opZNv1NXQp-N9dZK_032B_&token_type=bearer&state=ahometech&uid=729287204&account_id=dbid%3AAAAQnPFMxiNicQYa-1fVYKYp9HgwKa-JZOY

// Step 2. This local Path is set in my API http://localhost/mydropbox/xyz.php
// Step 3.  You can use according to your need */




// List contents of home directory

    if(isset($_GET["access_token"])&& !empty($_GET["access_token"])){

    $auth_token = $_GET["access_token"];
    $root_path = '/math/';
    // create curl resource
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_URL, "https://api.dropboxapi.com/2/files/list_folder");
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $auth_token, 'Content-Type: application/json'));
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array('path'=> $root_path,'recursive'=> true,'include_media_info'=> false,'include_deleted'=> false,'include_has_explicit_shared_members'=> false,'include_mounted_folders'=> true)));
    $result = curl_exec($ch);
    //print_r($result);
    $array = json_decode(trim($result), TRUE);
    //echo "<pre>";print_r($array);exit;
    curl_close($ch);
    }

1 comment: