Skip to content

Instantly share code, notes, and snippets.

@joesavak
Created June 3, 2011 17:54
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save joesavak/1006789 to your computer and use it in GitHub Desktop.
linkedinAuth
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: <%=@liapp %>
authorize: true
onLoad: onLinkedInLoad
</script>
<script type="text/javascript">
function onLinkedInLoad() {
IN.Event.on(IN, "auth", onLinkedInAuth);
$('#usingstoredLI').hide();
$('#linkedbutton').show();
};
function onLinkedInAuth() {
IN.API.Profile("me").result(storeProfile);
};
function storeProfile(profile){
member = profile.values[0];
$.post('/users/saveliuid', {
'liuid': member.id,
'liname': member.firstName + " " + member.lastName
},function(data) {
$('#usingstoredLI').show();
$('#linkedbutton').hide();
}, "json");
}
</script>
<span style="line-height: 1; vertical-align: middle">Auto-post on LinkedIn</span>
<% if current_user.li_name.blank? %>
<script type="in/Login">
<span id = "linkedbutton">
using account
<a href="" onclick="window.open('https://www.linkedin.com/settings/','_blank');return false;" >
<?js= firstName ?> <?js= lastName ?></a>.
</span>
</script>
<span id ="usingstoredLI" style="display:none;">
using account
<a href="" onclick="window.open('https://www.linkedin.com/settings/','_blank');return false;"><%=@user.li_name%></a>.
</span>
<% else %>
<span id ="usingstoredLI">
using account
<a href="" onclick="window.open('https://www.linkedin.com/settings/','_blank');return false;"><%=@user.li_name%></a>.
</span>
<script type="in/Login">
<span id = "linkedbutton" style="display:none;">
using account <a href="" onclick="window.open('https://www.linkedin.com/settings/','_blank');return false;" >
<?js= firstName ?> <?js= lastName ?></a>.</span>
</script>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment