barx Well-Known Member Licensed User Longtime User Nov 1, 2014 #1 Hey guys, Not B4A related at all, hence in the chit chat section. Anybody know how to use the Dropbox php SDK to authorize and use dropbox data stores? A link to a nice little tutorial would be nice
Hey guys, Not B4A related at all, hence in the chit chat section. Anybody know how to use the Dropbox php SDK to authorize and use dropbox data stores? A link to a nice little tutorial would be nice
DonManfred Expert Licensed User Longtime User Nov 1, 2014 #2 You know how to create a app in dropboxs app-console? Create your app, copy app key and secret Link to a small Tutorial ->| +~~~~~~~~~~~~~~~~ | ^ - Download http://fabi.me/en/php-projects/dropphp-dropbox-api-client/ - change sample.php PHP: $dropbox = new DropboxClient(array( 'app_key' => "yourkey", 'app_secret' => "yourecret", 'app_full_access' => false, ),'en'); - upload everything to webspace. - create a folder tokens where the php-scripts are) and make it writeable - make the folder where the php-scripts are writeable - execute sample.php (http://basic4android.de/dbx/sample.php) *big grins* Questions? PS: In fact i needed 15-30 minutes for all (including writing this post) to find the client and run the testexample with my credentials... I can not believe that you did not found an working example!? Maybe i was just in luck with my search and the first i found was working Attachments upload_2014-11-1_16-23-49.jpeg 1.4 KB · Views: 457 Last edited: Nov 1, 2014
You know how to create a app in dropboxs app-console? Create your app, copy app key and secret Link to a small Tutorial ->| +~~~~~~~~~~~~~~~~ | ^ - Download http://fabi.me/en/php-projects/dropphp-dropbox-api-client/ - change sample.php PHP: $dropbox = new DropboxClient(array( 'app_key' => "yourkey", 'app_secret' => "yourecret", 'app_full_access' => false, ),'en'); - upload everything to webspace. - create a folder tokens where the php-scripts are) and make it writeable - make the folder where the php-scripts are writeable - execute sample.php (http://basic4android.de/dbx/sample.php) *big grins* Questions? PS: In fact i needed 15-30 minutes for all (including writing this post) to find the client and run the testexample with my credentials... I can not believe that you did not found an working example!? Maybe i was just in luck with my search and the first i found was working
barx Well-Known Member Licensed User Longtime User Nov 1, 2014 #3 Hi @DonManfred I found a few (although I expected more) tutorials, the issue I had is that they all use 3rd party libs. And most of these libs only support File functions. I'm needing to use the Dropbox SDK and access DataStores . Most of the tutorials I have seen say that the bad thing about Dropbox SDK's is that there isn't a PHP one, yet I look and there it is. So I am guessing it is quite new.
Hi @DonManfred I found a few (although I expected more) tutorials, the issue I had is that they all use 3rd party libs. And most of these libs only support File functions. I'm needing to use the Dropbox SDK and access DataStores . Most of the tutorials I have seen say that the bad thing about Dropbox SDK's is that there isn't a PHP one, yet I look and there it is. So I am guessing it is quite new.
DonManfred Expert Licensed User Longtime User Nov 1, 2014 #4 barx said: So I am guessing it is quite new. Click to expand... no, not really but there is a php version too you can grab on dropbox site https://www.dropbox.com/developers/core/sdks/php DropPHP was the first i found and i have tested (successfully)
barx said: So I am guessing it is quite new. Click to expand... no, not really but there is a php version too you can grab on dropbox site https://www.dropbox.com/developers/core/sdks/php DropPHP was the first i found and i have tested (successfully)
barx Well-Known Member Licensed User Longtime User Nov 1, 2014 #5 DonManfred said: no, not really but there is a php version too you can grab on dropbox site https://www.dropbox.com/developers/core/sdks/php DropPHP was the first i found and i have tested (successfully) Click to expand... DropPHP doesn't seem to do DataStore access.
DonManfred said: no, not really but there is a php version too you can grab on dropbox site https://www.dropbox.com/developers/core/sdks/php DropPHP was the first i found and i have tested (successfully) Click to expand... DropPHP doesn't seem to do DataStore access.
DonManfred Expert Licensed User Longtime User Nov 2, 2014 #6 barx said: DropPHP doesn't seem to do DataStore access. Click to expand... It isn´t part of the Class and the sample, yes. But from principle it should CAN do this tasks... I´ve done a test i´ve inserted PHP: function GetDatastores($path) { return $this->apiCall("datastores/list_datastores", "GET", array()); } into Dropboxclient.php and i´ve edited my sample.php PHP: echo "<b>Datastores:</b>\r\n"; print_r($dropbox->GetDatastores("datastores/list_datastores")); after starting with some errors (wrong syntax i used) and i needed to create a new app (my old app did not have access to datastores) after creating the new app (WITH permissions for datastore) i got this working See http://basic4android.de/dbx/sample.php Datastores: stdClass Object ( [datastores] => Array() ) Click to expand... So i got no error(!) but also an empty list... I think it´s becaue i did not creaed a datastore before ;-) Actually i´m in good thoughts that datastore should be possible with this clientphp.... I´ll try to do more additions to the class and sample (creating a DS for ex)... I got my inspiration on page https://www.dropbox.com/developers/datastore/docs/http especially i tried to build one of the datastore-commands into the Clientphp See https://www.dropbox.com/developers/datastore/docs/http#list_datastores
barx said: DropPHP doesn't seem to do DataStore access. Click to expand... It isn´t part of the Class and the sample, yes. But from principle it should CAN do this tasks... I´ve done a test i´ve inserted PHP: function GetDatastores($path) { return $this->apiCall("datastores/list_datastores", "GET", array()); } into Dropboxclient.php and i´ve edited my sample.php PHP: echo "<b>Datastores:</b>\r\n"; print_r($dropbox->GetDatastores("datastores/list_datastores")); after starting with some errors (wrong syntax i used) and i needed to create a new app (my old app did not have access to datastores) after creating the new app (WITH permissions for datastore) i got this working See http://basic4android.de/dbx/sample.php Datastores: stdClass Object ( [datastores] => Array() ) Click to expand... So i got no error(!) but also an empty list... I think it´s becaue i did not creaed a datastore before ;-) Actually i´m in good thoughts that datastore should be possible with this clientphp.... I´ll try to do more additions to the class and sample (creating a DS for ex)... I got my inspiration on page https://www.dropbox.com/developers/datastore/docs/http especially i tried to build one of the datastore-commands into the Clientphp See https://www.dropbox.com/developers/datastore/docs/http#list_datastores
DonManfred Expert Licensed User Longtime User Nov 2, 2014 #7 Added quick & dirty PHP: function GetOrCreateDatastore($privateID){ return $this->apiCall("datastores/get_or_create_datastore", "POST", array("dsid"=>$privateID)); } to DropboxClient and added PHP: echo "<b>Datastore 'mannes' (get or create):</b>\r\n"; print_r($dropbox->GetOrCreateDatastore("mannes")); to sample.php See the new results PS: I´ll do more later but actually i need to go out for a few hours (Visit a friend)
Added quick & dirty PHP: function GetOrCreateDatastore($privateID){ return $this->apiCall("datastores/get_or_create_datastore", "POST", array("dsid"=>$privateID)); } to DropboxClient and added PHP: echo "<b>Datastore 'mannes' (get or create):</b>\r\n"; print_r($dropbox->GetOrCreateDatastore("mannes")); to sample.php See the new results PS: I´ll do more later but actually i need to go out for a few hours (Visit a friend)
DonManfred Expert Licensed User Longtime User Nov 2, 2014 #8 PHP: #echo "<b>Put Datastore 'mannes' DELTAs:</b>\r\n"; #$delta = $dropbox->PutDatastoreDelta($ds->handle, $ds->rev, "", "[[\"I\", \"members\", \"2\", {\"username\": \"ManfredTest\", \"eMail\": \"[email protected]\"}]]"); this adds one row with tableid = "members" record-id = 2 (can be a unique string too) record-fields: username= "ManfredTest" eMail = "[email protected] PHP: echo "<b>Get Datastore 'mannes' Snapshot:</b>\r\n"; $delta = $dropbox->GetSnapshot($ds->handle); print_r($delta); gets the hole contents of this datastore Code: stdClass Object ( [rows] => Array ( [0] => stdClass Object ( [tid] => tasks [data] => stdClass Object ( [taskname] => do laundry [completed] => ) [rowid] => myrecord ) [1] => stdClass Object ( [tid] => members [data] => stdClass Object ( [username] => DonManfred [eMail] => [email protected] ) [rowid] => 1 ) [2] => stdClass Object ( [tid] => members [data] => stdClass Object ( [username] => ManfredTest [eMail] => [email protected] ) [rowid] => 2 ) ) [rev] => 3 ) So. From principle it works to create DS, get DS, Inser Data into DS and get the complete data from DS Last edited: Nov 2, 2014
PHP: #echo "<b>Put Datastore 'mannes' DELTAs:</b>\r\n"; #$delta = $dropbox->PutDatastoreDelta($ds->handle, $ds->rev, "", "[[\"I\", \"members\", \"2\", {\"username\": \"ManfredTest\", \"eMail\": \"[email protected]\"}]]"); this adds one row with tableid = "members" record-id = 2 (can be a unique string too) record-fields: username= "ManfredTest" eMail = "[email protected] PHP: echo "<b>Get Datastore 'mannes' Snapshot:</b>\r\n"; $delta = $dropbox->GetSnapshot($ds->handle); print_r($delta); gets the hole contents of this datastore Code: stdClass Object ( [rows] => Array ( [0] => stdClass Object ( [tid] => tasks [data] => stdClass Object ( [taskname] => do laundry [completed] => ) [rowid] => myrecord ) [1] => stdClass Object ( [tid] => members [data] => stdClass Object ( [username] => DonManfred [eMail] => [email protected] ) [rowid] => 1 ) [2] => stdClass Object ( [tid] => members [data] => stdClass Object ( [username] => ManfredTest [eMail] => [email protected] ) [rowid] => 2 ) ) [rev] => 3 ) So. From principle it works to create DS, get DS, Inser Data into DS and get the complete data from DS
DonManfred Expert Licensed User Longtime User Nov 2, 2014 #9 I´ll package the files i´ve edited the next days. Today i dont have the time i suppose... Monday i have much less time too (it´s my cinema-day ;-)). What i have understand so far is (i´m not sure; i think it is like this!): The "I" in Adding Delta seems to be a command: I for Insert? The second parameter is the tablename the third parameter is the ID of this Row. Then you can use an - i think - unlimited numbers of columns which will be written to the selected table. What i did NOT understand actually; how to Update a row. And how to delete a row. Last edited: Nov 2, 2014
I´ll package the files i´ve edited the next days. Today i dont have the time i suppose... Monday i have much less time too (it´s my cinema-day ;-)). What i have understand so far is (i´m not sure; i think it is like this!): The "I" in Adding Delta seems to be a command: I for Insert? The second parameter is the tablename the third parameter is the ID of this Row. Then you can use an - i think - unlimited numbers of columns which will be written to the selected table. What i did NOT understand actually; how to Update a row. And how to delete a row.
DonManfred Expert Licensed User Longtime User Nov 4, 2014 #10 DonManfred said: The "I" in Adding Delta seems to be a command: I for Insert? Click to expand... Yes, it is! See this: <change> ::= ["I", <tid>, <recordid>, <datadict>] # INSERT | ["U", <tid>, <recordid>, <opdict>] # UPDATE | ["D", <tid>, <recordid>] # DELETE Click to expand... Documentation found here. You need to scroll a bit down on this link. I´ll try to do some tests on it the next days. I´ll keep you informed.
DonManfred said: The "I" in Adding Delta seems to be a command: I for Insert? Click to expand... Yes, it is! See this: <change> ::= ["I", <tid>, <recordid>, <datadict>] # INSERT | ["U", <tid>, <recordid>, <opdict>] # UPDATE | ["D", <tid>, <recordid>] # DELETE Click to expand... Documentation found here. You need to scroll a bit down on this link. I´ll try to do some tests on it the next days. I´ll keep you informed.