Skip to content

Instantly share code, notes, and snippets.

@dorianroy
dorianroy / gist:4168816
Created Nov 29, 2012
Parse URL parameter String from Dictionary
View gist:4168816
// create parameter string from parameter dictionary
__block NSMutableString *parameterString;
[parameters enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) {
if (!parameterString) parameterString = [NSMutableString stringWithString:@"?"];
else [parameterString appendString:@"&"];
// escape value string
NSString *escapedString = (__bridge NSString*)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)[parameters valueForKey:key], NULL, CFSTR(":/?#[]@!$&’()*+,;="), kCFStringEncodingUTF8);
[parameterString appendFormat:@"%@=%@", key, escapedString];
}];
View A friendly like button
<link rel="stylesheet" href="http://static.ak.fbcdn.net/rsrc.php/zD5ZK/hash/4146lpfk.css" type="text/css" />
<script type="text/javascript">
var fbURL = PASTE_FACEBOOK_URL_HERE;
function insertLikeButton() {
var container = document.getElementById('flbCont');
var w = container.style.width;
var h = container.style.height;
fbFrame = document.createElement("IFRAME");
fbFrame.setAttribute("src", fbURL);
fbFrame.setAttribute("scrolling", "no");