First off, thanks guys for your work with the Dropbox module. What a huge help it’s been for me. 2 THUMBS UP!
@Martin, I’ve been working with the module for a week now and can get and parse the Dropbox meta call.
Not sure where you are at integrating it, so I’ll just post a hard coded example, which I usually do until I get it working and then add in the functions that actually supply the needed params/ variables.
First, I manually created a folder in my Dropbox “Public” folder called, “MyTestFolder”
in my URL, I replaced “sandbox” with “dropbox” to get it to work.
I had to remove the lua tags around my code below as they are formatiing my code in an unusable long string…hmmmmm
– Gets metadata for the account.
function M.getMeta( path, listener )
--local url = “https://api.dropbox.com/1/metadata/sandbox/” … path … “?” … authString
– I’ve added the M.connect function to all my calls also, to make sure the user is signed in before trying to access the Dropbox account.
M.connect(consumer_key, consumer_secret, “sandbox”)
–notice the “/” following the folder name I want to browse
local FilePath = “Pulblic/MyTestFolder/”
local Listener = M.downloadDropboxMetaListener
local url = “https://api.dropbox.com/1/metadata/dropbox/” … FilePath … “?” … authString
network.request( url, “GET”, Listener )
end
OK, now you made the request for the meta for the specified Dropbox folder.
You will get a response from the request, the print will be called at the top of the dropboxListener()
Paste the listener code below into the module to read the response.
local JsonResponse --I declare it at the top of the module so I can use it elsewhere
function M.downloadDropboxMetaListener(event)
if ( event.isError ) then
print( “Network error!”)
else
print(“M.downloadDropboxMetaListener(event) has been called”)
print ( “RESPONSE: " … event.response )
JsonResponse = json.decode(event.response)
print(“JsonResponse == “, JsonResponse)
print(“JsonResponse.error == “, JsonResponse.error)
if JsonResponse.error == “Access token not found.” then
print(”<<<<<<<<<<<<<< JsonResponse.error == 'Access token not found.”)
native.showAlert(“Login to Dropbox!”], “First Login to Dropbox then select the action again.”, {“OK”}, noticeLoginToDropboxAndTryAgainStep2)
return
end
if #JsonResponse.contents < 1 then
print(”<<<<<<<<< There are NO Saved Registers!”)
native.showAlert(“Download Error: Empty Dropbox Folder!”, “The mTotal Admin must Upload the requested files.”, {“OK”}, noticeEmptyDropboxFolderStep2)
else
for i = 1, #JsonResponse.contents do
print(“JsonResponse.contents[”…i…”].path == ", JsonResponse.contents[i].path)
end
--call your function to process the response and load it into a scrollView
--loadDropBoxRScrollViewMenu()
end
end
end
I hope I don’t have a typo in there somewhere, it should work. I had to remove a bunch of code out of the listener that I use in my app, but this should get you headed in the right direction.
Hope this helps.
Nail