Sunday, February 23, 2014

sign-in with linkedin with js API - learnmore at www.i-visionblog.com

LinkedIn provides excellent sign-in system to enable the user to login and experience the privacy via profiles.so,LinkedIn documentations are very helpful in nature and provides excellent explanation towards purpose. LinkedIn is professional profile website that can create jobs,connections and various aspects.it has both free service and paid up-gradable services.So,let us see about the sign-in with LinkedIn for our website.
first go to Application create site and register your application with ACCURATE DOMAIN ADDRESS that include sub-domain and port option also.in the JS API text area with comma if multiple address and get your APP_KEY.
sign-in with linkedIn -s.shivasurya i-visionblog.com
sa

DEMO -take a demo rite here

JavaScript for Authentication:

<script type="text/javascript" src="http://platform.linkedin.com/in.js">
  api_key: YOUR_API_KEY
  authorize: true
</script>

this script is used to show the sign-in button and check the user had already authenticated using the particular app.

Javascript for displaying Info:


<script type="IN/Login"> 
<form action="/register.html"> 
<p>Your Name: <input type="text" name="name" value="<?js= firstName ?> <?js= lastName ?>" /></p>
<input type="hidden" name="linkedin-id" value="<?js= id ?>" />
<input type="submit" name="submit" value="Sign Up"/>
</form>
</script>

replace your app id and save it as html file.final code that appears below.

html code:

<html>
<head>
<title>linkedin API login</title>

<script type="text/javascript" src="http://platform.linkedin.com/in.js">
  api_key: your app_key
  authorize: true
</script>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <script type="text/javascript" src="http://code.jquery.com/jquery-1.5b1.js"></script>
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.min.js"></script>  
</head>
<body class="yui3-skin-sam yui-skin-sam">
    <script type="IN/Login"> 
<h1>welcome,<?js= firstName ?><?js= lastName ?> </h1>
<p>Your Name: <input type="text" name="name" value="<?js= firstName ?> <?js= lastName ?>" /></p>
<input type="hidden" name="linkedin-id" value="<?js= id ?>" />
</script>
</body>
</html>


some common issues:


1)since we are using <?=js this may have effect in PHP short tags so i am making this project inside a directory and created .htaccess and switched off the short tag using the code in .htaccess file

2)Sometime while loading the page and you would not see the sign up botton at the page,so don't worry, just check your domain properly registered at app settings at linkedin developers app page.And if error occurs check out the console at the browser.

if you experience any errors just notify as comments.share is care.

0 comments:

Post a Comment

feel free to post your comments! Don't Spam here!