0

This might sound trivial for some of you, but I need to be sure...

I simply need to use dropbox for 2 things :

  • upload image files via php from my web server with the possibility of creating folder (as I would do on a normal web server) or sync folders from my web server to dropbox via rsync;

  • display these image files in a web page

I have downloaded the api sdk, then run into the 64bit exception error, then invalid redirect-uri...

So I would really appreciate if someone can reply to my 2 questions above and point me to a good example to just do that.

Paul Godard
  • 1,055
  • 1
  • 14
  • 30
  • I don't have any code yet, I am only using the examples provided in the sdk. – Paul Godard Jan 08 '14 at 13:24
  • 1
    You can hack round the 64bit problem by just commenting out the line which throws the exception in [lib/Dropbox/RequestUtil.php](https://github.com/dropbox/dropbox-sdk-php/blob/master/lib/Dropbox/RequestUtil.php) - look at line 22. Be prepared for unexpected results ;-) – madebydavid Jan 08 '14 at 15:59
  • I have done that, then I got the invalid uri... So now before I dig further, I am looking to see if dropbox will work for me. Please reply to my generic questions and send me some pointers... thanks – Paul Godard Jan 09 '14 at 15:42
  • Did you set the "OAuth redirect URIs" in the App console for your app? https://www.dropbox.com/developers/apps/? If you are developing locally this might be something like http://localhost/myproject/oauth or whatever. Look at the web-file-browser.php example in the PHP SDK. Without code it's tricky to help you further. – madebydavid Jan 09 '14 at 20:35
  • As I said, I have written any code yet but only tested the example you just mentioned (web-file-browser.php). – Paul Godard Jan 11 '14 at 07:26
  • Apart testing the file above, can someone tell me if I can do the 2 above things I have mentioned above? – Paul Godard Jan 11 '14 at 07:27

2 Answers2

2

I solved it in another way. Rather than displaying the raw-file I use the API to generate Direct Download Link. This will give me a weblink that I then modify by adding a "raw=1" and subsitute the "dl=0" with "dl=1". This new link than then be used as the source for a normal html image.

1

As per above suggestions

import dropbox
import json
import httplib, urllib, base64

access_token='your token'
client = dropbox.client.DropboxClient(access_token)
url = client.share('test.jpg',short_url=False)
imageurl = url['url'].replace("dl=0","raw=1")

body = {
"url":imageurl
}
print json.dumps(body) 

headers = {
# Request headers
'Content-Type': 'application/json',
'Ocp-Apim-Subscription-Key': '00759a20e705487a91e4db51b80bdfa7',
 }

params = urllib.urlencode({
}) 

try:
conn = httplib.HTTPSConnection('api.projectoxford.ai')
conn.request("POST", "/emotion/v1.0/recognize?%s" % params,json.dumps(body),        headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
user3280908
  • 162
  • 1
  • 7