Can't post keywords with double-quotes

darryldarryl Registered Users Posts: 997 Major grins
Man, this is super-frustrating.

In the web UI, if you enter a keyword in "double quotes", as advised by the help pages, it ends up in the database (as retrieved by images.getInfo) as "double quotes".

Fine, I can [post=657463]parse for that[/post]. But when I go to write keywords back out, I'm trying to use the API like so:
$changeinfo = $browser->post('http://api.smugmug.com/hack/rest/1.2.0/',
['method'=>'smugmug.images.changeSettings',
'SessionID'=>"$sessionid",
'ImageID'=>"$updateimage",
'Keywords'=>"$newkeywordstext"],) ;

If $newkeywordstext contains double-quotes (ex. "ty"), they appear in the web UI prepended with a \, and when I go back with an images.getInfo call, it shows up as:

\"ty\"

Blech. Ok, maybe I should try to HTML encode the double-quotes myself. So I try posting: "ty"

This time images.getInfo gives me the equally ugly:
"ty"

Nasty. I don't want to use semi-colons! Double-quotes make sense to me and to the non-coders that may be editing keywords. Also, I *need* double-quotes so that keywords < 4 characters will be recognized as keywords. Argh!

Any other suggestions on getting the API to properly accept double-quote characters? It kind of sucks when functionality on the website isn't duplicated in the API.

Comments

  • darryldarryl Registered Users Posts: 997 Major grins
    edited October 16, 2007
    Based on some info from [post=656837]this post[/post], I tried some further experimentation with images.changeSettings in the API:
    Posted: &quot;ty&quot;
    Got: &amp;quot;ty&amp;quot;
    
    Posted:  %26quot;ty%26quot;
    Got: %26quot;ty%26quot;
    
    Posted: "ty"
    Got: \&quot;ty\&quot;
    

    On the site, only the last one actually resulted in the keyword being properly recognized.

    It's annoying though that if you manually type "ty" on the site, it turns into: "ty" without the extraneous backslashes.
  • lukebakerlukebaker Registered Users Posts: 8 Beginner grinner
    edited December 9, 2007
    Bump.

    I ran into this issue as well. What is the recommened practice for submitting keywords with double quotes via the API? Thanks.
  • darryldarryl Registered Users Posts: 997 Major grins
    edited December 10, 2007
    I ended up just using double-quotes, like "this sucks"

    If human users end up looking at that keyword, they'll see:

    \"this sucks\"

    And using the API call to get quotes, I still get \"this sucks\"

    I couldn't find any way around it, so I just use this annoying regexp to fix it before I start to deal with keywords:

    $oldkeywords =~ s|\\"|"|g ;

    Here's my whole [post=684695]keyword parsing subroutine[/post]
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited December 10, 2007
    lukebaker wrote:
    Bump.

    I ran into this issue as well. What is the recommened practice for submitting keywords with double quotes via the API? Thanks.

    Luke,

    You can use semi-colons to seperate keywords, eg.

    keyword1; keyword two; more key words;

    Cheers,

    David
    David Parry
    SmugMug API Developer
    My Photos
  • lukebakerlukebaker Registered Users Posts: 8 Beginner grinner
    edited December 11, 2007
    devbobo wrote:
    You can use semi-colons to seperate keywords, eg.

    keyword1; keyword two; more key words;

    I have the following keywords:
    5 star hotel; indianapolis;

    The 5 star hotel keyword does not show up when viewing the page, but will show up when I edit my keywords. It works with double-quotes, excepting the API bug.
  • pe2smugmugpe2smugmug Registered Users Posts: 53 Big grins
    edited January 7, 2008
    bump.

    Is there any new info on this? I'm having a very similar problem with at least my captions and my keywords.

    Using the 1.2.0 JSON interface, posting a string that starts and ends with a ", leads to the entire string being escaped, causing some interesting problems.

    Using an older XML-RPC interface did NOT have the problem, and the text appears as entered.
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited January 8, 2008
    I have fixed this issue internally, hopefully I can roll the changes out soon.
    David Parry
    SmugMug API Developer
    My Photos
  • pe2smugmugpe2smugmug Registered Users Posts: 53 Big grins
    edited January 8, 2008
    devbobo wrote:
    I have fixed this issue internally, hopefully I can roll the changes out soon.

    Thanks David!
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited January 12, 2008
    This should now be fixed in api version 1.2.0/1.2.1.

    Please let me know if you have any issues.
    David Parry
    SmugMug API Developer
    My Photos
Sign In or Register to comment.