Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL for buddy icon #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Source/ObjectiveFlickr.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ extern NSString *const OFFlickrDeletePermission;

// URL provisioning
- (NSURL *)photoSourceURLFromDictionary:(NSDictionary *)inDictionary size:(NSString *)inSizeModifier;
- (NSURL *)buddyIconSourceURLFromDictionary:(NSDictionary *)inDictionary;
- (NSURL *)photoWebPageURLFromDictionary:(NSDictionary *)inDictionary;
- (NSURL *)loginURLFromFrobDictionary:(NSDictionary *)inFrob requestedPermission:(NSString *)inPermission;

Expand Down
26 changes: 26 additions & 0 deletions Source/ObjectiveFlickr.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,32 @@ - (NSURL *)photoSourceURLFromDictionary:(NSDictionary *)inDictionary size:(NSStr
return [NSURL URLWithString:URLString];
}

- (NSURL *)buddyIconSourceURLFromDictionary:(NSDictionary *)inDictionary
{
// http://farm{iconfarm}.static.flickr.com/{iconserver}/buddyicons/{nsid}.jpg
// http://www.flickr.com/images/buddyicon.jpg

NSString *server = [inDictionary objectForKey:@"iconserver"];
NSString *nsid = [inDictionary objectForKey:@"nsid"];

if (![server length] || [server intValue] <= 0 || ![nsid length]) {
return [NSURL URLWithString:@"http://www.flickr.com/images/buddyicon.jpg"];
}

NSMutableString *URLString = [NSMutableString stringWithString:@"http://"];

NSString *farm = [inDictionary objectForKey:@"iconfarm"];
if ([farm length]) {
[URLString appendFormat:@"farm%@.", farm];
}

[URLString appendFormat:@"static.flickr.com/%@/buddyicons/%@.jpg",
server, nsid];

return [NSURL URLWithString:URLString];
}


- (NSURL *)photoWebPageURLFromDictionary:(NSDictionary *)inDictionary
{
return [NSURL URLWithString:[NSString stringWithFormat:@"%@%@/%@", photoWebPageSource, [inDictionary objectForKey:@"owner"], [inDictionary objectForKey:@"id"]]];
Expand Down