The place to discuss how to make 23 work in special ways with the 23 api

uploading images via API

magnatronus   February 15, 2006, 01:32 PM

I can currently upload images to Flickr using a post to [flickr url]/services/upload.

If I substitute [flickr url] for [23hq url] the call will function but it always returns Login failed / Invalid auth token.

If I use the auth token from the upload call in one of the other 23Hq REST calls it works fine ( i.e. flickr.people.getUploadStatus).

The bit I'm not sure about is

a. Flickr need a 'SECRET' value
b. The call also needs an api_signature( MD5)

I have tried both with and without these values but the result is the same.

Can you point me in the right direction( I am obviously doing something wrong) - also any chance of an actual example for upload like the Flickr Site?

thanks.

 
Jordi Funollet   February 15, 2006, 06:00 PM

Hi Magnatronus,

I'm using a dirty Python script to upload photos from my Linux desktop. It's not finished but "Works For Me"; here it is.

Actualy it gets authentication data from a file '$HOME/.upload23', wich contains:

# -----------------------------------
[auth]
api_key=DEMO
username=magnatronus
password=verysecret
# -----------------------------------

Take a look at the services_upload() function, who's really doing the job.

There's also a curl-upload explanation on the 23 Blog, a really nice starting point.

 
Steffen Fagerström Christensen Team 23   February 16, 2006, 12:48 PM

Hey, still having problems after looking at the examples? In that case, I'll write up a decent explanation with curl examples...

 
magnatronus   February 16, 2006, 01:40 PM

Not problems as such. But the examples use the username and password login. I am trying to do this by using the AuthCode( as per Flickr). so some examples of this would be great.

- thanks.

 
Steffen Fagerström Christensen Team 23   February 16, 2006, 01:42 PM

I'll provide you with some samples within a few hours, then ;-)

 
Steffen Fagerström Christensen Team 23   February 16, 2006, 03:55 PM

OK, this works for me:

a) Request a frob
Macintosh:~/ comp$ curl -F api_key=23demo -F method=auth.getFrob http://www.23hq.com/services/rest/


MYFROB


b) Validate frob by going to:
http://www.23hq.com/services/auth/?api_key=23demo&frob=MYFROB


c)
Macintosh:~/ comp$ curl -F api_key=23demo -F method=auth.getToken -F frob=MYFROB http://www.23hq.com/services/rest/



MYTOKEN
delete





d) Upload the photo
Macintosh:~/ comp$ curl -F api_key=23demo -F auth_token=MYTOKEN -F photo=@myphoto.jpg http://www.23hq.com/services/upload/


426294

 
magnatronus   February 16, 2006, 04:19 PM

Thanks I'll give it a go and let you know. It was just the last step (d) that was failing for me originally.

 
magnatronus   February 17, 2006, 09:33 AM

well I am still getting the "Login failed / Invalid auth token" error when trying to upload an image. I an using java( btw the routines work fine with Flickr). I have redirected the post that is done to a local server so I can get a copy of the output which is included here:

POST /services/upload HTTP/1.1
Content-Type: multipart/form-data; boundary=---------------------------7d42082230740
Cache-Control: no-cache
Pragma: no-cache
User-Agent: Java/1.4.2_05
Host: www.23hq.com
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Content-Length: 24530
-----------------------------7d42082230740
Content-Disposition: form-data; name="photo"; filename="grumpyas.jpg"
Content-Type: image/jpeg

[data here is the image data - removed for clarity]

-----------------------------7d42082230740
Content-Disposition: form-data; name="auth_token"
EB_MY_AUTH_TOKEN
-----------------------------7d42082230740
Content-Disposition: form-data; name="api_key"
MY_API_KEY
-----------------------------7d42082230740--


The auth key is not the problem as I also have an addtags function and if I manually upload an image then use the addtags method it works fine. So basically it is just the upload that gives me the error - any ideas???

 
magnatronus   February 17, 2006, 10:37 AM

I have tried a couple more api calls from my Flickr Library:

flickr.photos.addTags - works fine

flickr.photos.setMeta - gives an error - "Server returned HTTP response code: 403 for URL: http://www.23hq.com/services/rest"

both these routines share the same post routine only the parameters are different.

 
Steffen Fagerström Christensen Team 23   February 17, 2006, 11:30 AM

First, try posting to "/services/upload/" rather than merely "/services/upload" -- it's unlikely that it changes anything, but it may...
Otherwise, please send me the full request including the "real" token to steffen@23hq.com (if you're unsure about that, remove the last five or six chars from the token, I'll look the full token it up in the db)

/Stc

 
magnatronus   February 17, 2006, 01:16 PM

OK,

Great that sorted it.... if I upload to /services/upload it fails with the auth error, if I use /services/upload/ it works ok

I have also been testing the other calls we use as well and the only problem so far is the flickr.photos.setMeta problem I mentioned earlier.


- thanks for the help.

 
Steffen Fagerström Christensen Team 23   February 17, 2006, 11:08 PM

The bug in setMeta has been resolved now. I'll be back to do the rss thingy after the weekend.

 
AdamsPlugins   February 18, 2006, 05:54 AM

Two things:
- upload seemed to ignore the isPublic flag, my photo was still private. I believe this flag should override the user preference
- my first upload included html tags in the description (flickr allows them). I got an HTML page returned. I would have preffered to see an XML response with some sort of error code, it would have been easier to track down.

- okay, maybe a few more things... can we add a few things to the switch documentations e.g. differences between flickr tags and 23 tags (flickr strips out non a-z,0-9)

- based on the behaivour of the search screen I'm guessing I can do tag based searches that return non-exact hits. e.g. searching on "Photo" will return photos tagged with "PhotoMap". Is this correct? Can I stop this (not sure I want to but it would be nice to know).

- are tags case-sensative? The behaviour seems inconsistant:
e.g search on PhotoMap gives no hits, but navigate to
http://www.23hq.com/tag/PhotoMap shows a picture

Adam
http://photomap.mozdev.org

 
Steffen Fagerström Christensen Team 23   February 18, 2006, 06:48 AM

Hi Adam,

I'm on my way out for the weekend, but I wanted to give you an answer to some of your questions right away:

a) The parameter is "is_public" rather than "ispublic", and it works okay for me at the moment?

b) Yeah, you're right. I've allowed html for the moment, but I'll be back on Monday to do a cleanup, which will return errors in XML.

c) Basically, we're allowing everything apart from a "$" and {[]}. We have been looking at doing comparisons and other stuff by stripping some chars and making them "raw tags", but it's not implemented at the moment.

d) I'll look into this. For this purpose, we'll do it the way Flickr is doing it -- that should solve any unexpected behaviour, right?

e) This seems weird, and it certainly isn't by design. Once again, I'll be back to change this either tomorrow or on Monday.

 
AdamsPlugins   February 18, 2006, 01:55 PM

With respect to partial matches
- supporting partial matches is actually prefered, I could then drop a lot of the tags I add to pictures to support this in flickr (e.g. I want to find all pictures tagged with tags that start "geo:long=45".
- I just think we also need a way to trigger the opposite behaviour, and documentation about which the default is e.g. search for Photo$ v.s. Photo v.s. Photo* v.s. /Photo.* etc.

Adam

 
Steffen Fagerström Christensen Team 23   February 18, 2006, 03:28 PM

With regard to tag searching and partial/mixed case matches, the discussion has been moved here:
http://www.23hq.com/forums/message-view?message_id=429648

 
Steffen Fagerström Christensen Team 23   February 20, 2006, 08:45 PM

Apparently my previous comment about some "rss thingy" wasn't in answer to this thread -- but I won't keep you in suspence:

The RSS implementation for user comments can be found here (the user's Conversions):
http://www.23hq.com/rss/[username]/a/conversations
http://www.23hq.com/rss/[username]/a/conversations/comment
http://www.23hq.com/rss/[username]/a/conversations/contact

 




About 23

About 23
What is 23 and who's behind the service?
Just In
Discover the world from a different angle.
Here's a crop of the latest photos from the around the world.
Search
Search photos from users using 23
Help / Discussion
Get help or share your ideas to make 23 better
23 Blog / 23 on Twitter
Messages and observations from Team 23
Terms of use
What can 23 be used for and what isn't allowed
More services from 23
We also help people use photo sharing in their professional lives
RSS Feed
Subscribe to these photos in an RSS reader
  • Basque (ES)
  • Bulgarian (BG)
  • Chinese (CN)
  • Chinese (TW)
  • Danish (DK)
  • Dutch (NL)
  • English (US)
  • French (FR)
  • Galician (ES)
  • German (DE)
  • Italian (IT)
  • Norwegian (NO)
  • Polish (PL)
  • Portuguese (PT)
  • Russian (RU)
  • Spanish (ES)
  • Swedish (SE)

Popular photos right now