Skip to content

Instantly share code, notes, and snippets.

@bradhintze
Created November 21, 2010 21:41
Show Gist options
  • Save bradhintze/709177 to your computer and use it in GitHub Desktop.
Save bradhintze/709177 to your computer and use it in GitHub Desktop.
Test for Facebook authentication. If there is none, then the user is prompted to allow access to the permissions requested.
meta {
name "Facebook Groups in Search Results"
description <<
Kynetx Facebook Integration
>>
author "bjo"
key facebook {
"consumer_key":"REDACTED",
"consumer_secret":"REDACTED"
}
logging off
}
dispatch {
}
global {
}
rule auth_app is active {
select using ".*" setting ()
if ( not facebook:authorized())
then
facebook:authorize(["read_stream","offline_access","user_status","friends_status","friends_about_me","publish_stream",
"email","user_photos","user_likes","user_online_presence","friends_photos","user_groups","friends_groups" ])
with opacity = 1 and
sticky = true;
fired {
last;
}
}
rule facebook_pop is active {
select when pageview "^http://(?:www|search).(?:bing|google|yahoo).com/.*(?:search|#hl|#sclient|webhp).*(?:&|\?)(?:p|q)=(.*?)(:?&|$)" setting (searchTerm)
foreach facebook:search({"type" : "group", "q" : searchTerm, "limit":5}).pick("$..data") setting (group)
pre {
gName = group.pick("$.name");
gId = group.pick("$.id");
picUrl = facebook:picture({"id":gId,"type":"square"});
div = << <div style="height:40px;"><img src="#{picUrl}" style="float:left;" /><p style="font-size:14px;float:left;padding-left:5px;"><a href="http://www.facebook.com/group.php?gid=#{gId}" >#{gName}</a></p></div><br /> >>;
}
prepend("#res", div);
}
rule facebook_pop is active {
select when pageview "^http://(?:www|search).(?:bing|google|yahoo).com/.*(?:search|#hl|#sclient|webhp).*(?:&|\?)(?:p|q)=(.*?)(:?&|$)" setting (searchTerm)
foreach facebook:search({"type" : "group", "q" : searchTerm, "limit":5}).pick("$..data") setting (group)
pre {
gName = group.pick("$.name");
gId = group.pick("$.id");
picUrl = facebook:picture({"id":gId,"type":"square"});
div = << <div style="height:40px;"><img src="#{picUrl}" style="float:left;" /><p style="font-size:14px;float:left;padding-left:5px;"><a href="http://www.facebook.com/group.php?gid=#{gId}" >#{gName}</a></p></div><br /> >>;
}
prepend("#res", div);
}
rule auth_app is active {
select using ".*" setting ()
if ( not facebook:authorized())
then
facebook:authorize(["read_stream","offline_access","user_status","friends_status","friends_about_me","publish_stream",
"email","user_photos","user_likes","user_online_presence","friends_photos","user_groups","friends_groups" ])
with opacity = 1 and
sticky = true;
fired {
last;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment