Flickr4Java
Flickr4Java copied to clipboard
Add flickr.people.search
Subject of the issue
Please add to PeopleInterface the method flickr.people.search
Your environment
- 2.16
- 1.8
Hi @ctaity I can't find that method in The Flickr API documentation. Do you have any more details about it please?
Yes, is not document but....
private static final String SEARCH_METHOD = "flickr.people.search";
private URI getSearchUri(int page, String searchName) throws URISyntaxException, IOException {
return new URIBuilder(API_URL)
.addParameter("username", searchName)
.addParameter("api_key", this.getSiteToken())
.addParameter("method", SEARCH_METHOD)
.addParameter("exact", "0")
.addParameter("per_page", String.valueOf(RESULTS_PER_PAGE))
.addParameter("perPage", String.valueOf(RESULTS_PER_PAGE))
.addParameter("page", String.valueOf(page))
.addParameter("loadFullContact", "1")
.addParameter("format", "json")
.addParameter("show_more", "1")
.addParameter("nojsoncallback", "1")
.addParameter("extras", "date_joined,path_alias,rev_ignored,rev_contacts,icon_urls,location,rev_contact_count,use_vespa")
.build();
}
and now i am geeting the site token from flickr index.
private static final String REGEX_SITE_KEY = "root.YUI_config.flickr.api.site_key = \"(?<key>.*)\"";
protected void refreshSiteKey() throws IOException {
final String source = RequestUtils.getDocument(FLICKR_URL).html();
final Matcher siteKeyMatcher = PATTERN_SITE_KEY.matcher(source);
final Matcher siteKeyExpiresMatcher = PATTERN_SITE_KEY_EXPIRES.matcher(source);
if (!siteKeyMatcher.find() || !siteKeyExpiresMatcher.find())
throw new IOException("Cannot get site_key or expires");
siteKey = siteKeyMatcher.group("key");
expiresSiteKey = 1000 * Long.valueOf(siteKeyExpiresMatcher.group("ts")); //with miliseconds
}
protected String getSiteToken() throws IOException {
if (expiresSiteKey < System.currentTimeMillis() + SAFE_SEARCH_TIME)
this.refreshSiteKey();
return siteKey;
}
Hello. I can't get it working sorry. I did some test code to call the method but it just failed.
How does this differ from flickr.people.findByUsername anyway? Can't you just use that?
can you share with me the test? This search is called from flickr in the public search of profiles, is a different search, is not only by username.
private static final String API_URL = "https://api.flickr.com/services/rest";
Here you go, I've pushed my branch. https://github.com/boncey/Flickr4Java/tree/user-search
Refer to the README on how to run the tests.
Thanks, i going to checkout.