Tell me more ×
SmugMug Stack Exchange is a question and answer site for SmugMug developers and end users. It's 100% free, no registration required.

I'm doing an integration of SmugMug and WordPress and I'm looking for a way to search a users SmugMug account from within the local site. Although I'm using WP this applies much wider and input or advice from anyone who has done something similar would be much appreciated!

As of now, I see a few approaches:

1) Have a script post a search-term to to the SmugMug engine and "rake" the results to display. Not very elegant, but would be fast and benefit from the SmugMug engine finesse.

2) Faking links to feeds and implement it as search result

3) Using the API to (at regular intervals) build a local library, searching this instead of the actual live data at SmugMug.

4) Waiting for the 1.4.0 API and hope that will include search support...

How would/did YOU do it?

share|improve this question

2 Answers

up vote 3 down vote accepted

[UPDATE]

What is a good way to search on keywords using the SmugMug API?

I just stumbled across the question above and it got me to poking around with the /hack/feed.mg URL. It looks like you'll be able to search within your site and get the results back. The question above uses Type=userKeyword, which appears to only search through keywords. I was able to change it to 'Type=usersearch' and it appears to be doing a text search of titles, captions, and keywords.

http://brianweller.smugmug.com/hack/feed.mg?Type=usersearch&NickName=brianweller&Data=church&format=rss200

[/UPDATE]

Screen scraping is usually frowned upon (a lot of times violating the TOS), and typically a brittle long term solution.

It looks like this might be getting added in the 4.0 API. The smugmug search seems to be dogfooding this call at the moment.

Searching for 'dog' reveals that a GET request to http://www.smugmug.com/search/?searchWords=dog&searchType=global&x=0&y=0 is made.

Scrolling down to the end of the page, it appears that a JSON request is made to http://www.smugmug.com/services/api/json/1.4.0/?Query=dog&Start=48&Size=16&Facets=%7B%7D&NickName=&SortBy=popular&method=rpc.search.images

There's nothing on the wiki about the 4.0 APIs, so you're completely on your own here, but I would imagine that would be the best compromise, given your constraints.

share|improve this answer
Thanks, that's a very informative answer. May I ask how you found the JSON request? Can't see it in the sources. Using this I can probably hack my own requests until the wonderful day they release 1.4.0... Too bad the PHP endpoint isn't open yet! – HaavardH Apr 25 '12 at 1:48
Sorry, I didn't get a notification of your comment. I opened up the Firebug console (the Net tab specifically), but basically any proxy that lets you review the requests being made by your browser would work. You'll see a bunch of css, image and js requests. You'll have to scroll to the bottom of the search results page in order to trigger the javascript code that makes the request for more images. – Brian Weller May 13 '12 at 21:22
Ah I see, thanks again. And it worked out beautifully! – HaavardH May 14 '12 at 2:47
Bah, they must have changed something now, whenever I supply the Nickname parameter with a value it comes back empty :( help? – HaavardH May 15 '12 at 13:28
Sorry man...I just tried poking around with this API and it looks like they're still passing the NickName argument, but that if you pass anything to it, you get no results. I tried some queries that should have returned results from my own collection, but nothing. That's the way these things go sometimes...if it isn't officially released and being supported, it's subject to the whims of the dev team at SmugMug. – Brian Weller May 31 '12 at 13:33
show 2 more comments

I took a different approach when I wanted to do the search in my site. I created a Wordpress widget that contains the following code

<form method="get" class="searchform" action="http://photos.bradfordbenn.com/search/index.mg">
<input type="text" value="Search Photos" name="searchWords" class="searchfield" onfocus="if (this.value == 'Search Photos') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search';}" />

It works for me without an issue and includes the ability that on my site so when someone does the search it launches directly into my SmugMug site.

share|improve this answer
Thanks for the input (and I enjoyed your site!), but I want to shape the output and display it locally. The goal being to use SM strictly as an image database. – HaavardH Jun 2 '12 at 11:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.