That code shows how to add tags to items, so you just have to loop over items and tags and follow the code in example.php...
---
Problems? Check gallery3/var/logs bugs/feature req's | upgrade to the latest code | use git
bharat
Joined: 2002-05-21
Posts: 7985
Posted: Wed, 2010-08-11 02:31
Oh-- a desktop client. Got it. You're probably not using the PHP library implementation
First create all the tags you want to use by posting to /rest/tags. Here's an example that creates a tag named "My Tag".
POST /gallery3/index.php/rest/tags HTTP/1.1
Host: example.com
X-Gallery-Request-Method: post
X-Gallery-Request-Key: d43b3cc27c3db0c74eb64a471e570860
Content-Type: application/x-www-form-urlencoded
Content-Length: 38
entity=%7B%22name%22%3A%22My+Tag%22%7D
Once you've got your tags you can then add photos, then get the url of the tags relationship from the photo and POST to it. Here's an example tagging request:
POST /~bharat/gallery3/index.php/rest/item_tags/12 HTTP/1.1
Host: example.com
X-Gallery-Request-Method: post
X-Gallery-Request-Key: d43b3cc27c3db0c74eb64a471e570860
Content-Type: application/x-www-form-urlencoded
Content-Length: 267
entity=%7B%22tag%22%3A%22http%3A%5C%2F%5C%2Fexample.com%5C%2Fgallery3%5C%2Findex.php%5C%2Frest%5C%2Ftag%5C%2F11%22%2C%22item%22%3A%22http%3A%5C%2F%5C%2Fexample.com%2Fgallery3%5C%2Findex.php%5C%2Frest%5C%2Fitem%5C%2F1%22%7D
Unfortunately (when creating the tags at least) unless I've got my request wrong it seems to take only the last part of a multipart request, ignoring the rest. I'm still trying to get my head around it but looking at the php it seems thats what should happen.
If so is there any chance it could be modified so you can send something like
not sure what is best, but have the end result that tag1, tag2 and tag3 are created in one request.
I would look into making a patch myself but I'm not sure of the best way to go about it, or even if it should be done. That and the fact that php seems to be completely unintelligible to me at the moment.
bharat
Joined: 2002-05-21
Posts: 7985
Posted: Thu, 2010-08-12 04:24
Multipart isn't supported. I think it's reasonable to add multiple tags at once, but we don't support that currently. Please file a ticket for it.
---
Problems? Check gallery3/var/logs bugs/feature req's | upgrade to the latest code | use git
rak
Joined: 2010-08-09
Posts: 44
Posted: Thu, 2010-08-12 12:22
Is it ok to create the relationships by posting to "http://example.com/gallery3/index.php/rest/item_tags/" (without the item number) or is that bad practice?
If its ok would you consider allowing multiple tag-item relationships to be created per request?
bharat
Joined: 2002-05-21
Posts: 7985
Posted: Fri, 2010-08-13 07:39
Yes it's ok to just post to /rest/item_tags without an id. I'll look into allowing multiple relationships in a single post.
---
Problems? Check gallery3/var/logs bugs/feature req's | upgrade to the latest code | use git
Posts: 7985
What do you have so far? Are you using the Gallery3.php API from here? http://github.com/gallery/gallery3-contrib/tree/master/client/
That code shows how to add tags to items, so you just have to loop over items and tags and follow the code in example.php...
---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git
Posts: 7985
Oh-- a desktop client. Got it. You're probably not using the PHP library implementation
First create all the tags you want to use by posting to /rest/tags. Here's an example that creates a tag named "My Tag".
Once you've got your tags you can then add photos, then get the url of the tags relationship from the photo and POST to it. Here's an example tagging request:
The entity array contains:
entity = { tag: http://example.com/gallery3/index.php/rest/tag/11 item: http://example.com/gallery3/index.php/rest/item/1 }It creates a relationship between the two. Hope that helps!
---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git
Posts: 44
Sorry if I'm missing something, but does this mean you can only create 1 relationship per request?
(I'm just trying to work out the best way to do it with the minimal number of requests as they're what slows everything down)
Posts: 225
Could you do a multipart request form? (content-type: multipart/form-data)
Tomek
----
Publish on Gallery 3 (WLPG Plugin) | XMP Module
Posts: 44
Unfortunately (when creating the tags at least) unless I've got my request wrong it seems to take only the last part of a multipart request, ignoring the rest. I'm still trying to get my head around it but looking at the php it seems thats what should happen.
If so is there any chance it could be modified so you can send something like
entity = { 'name' : 'tag1', 'name' : 'tag2', 'name' : 'tag3' }or maybe
entity = { 'name' : { 'tag1', 'tag2', 'tag3' } }not sure what is best, but have the end result that tag1, tag2 and tag3 are created in one request.
I would look into making a patch myself but I'm not sure of the best way to go about it, or even if it should be done. That and the fact that php seems to be completely unintelligible to me at the moment.
Posts: 7985
Multipart isn't supported. I think it's reasonable to add multiple tags at once, but we don't support that currently. Please file a ticket for it.
---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git
Posts: 44
Is it ok to create the relationships by posting to "http://example.com/gallery3/index.php/rest/item_tags/" (without the item number) or is that bad practice?
If its ok would you consider allowing multiple tag-item relationships to be created per request?
Posts: 7985
Yes it's ok to just post to /rest/item_tags without an id. I'll look into allowing multiple relationships in a single post.
---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git