+ Start a Discussion
Salesforce@322Salesforce@322 

Integration - salesforce with linkedIn

Hi,


I am new to salesforce integration,i got a requirement as to integrate salesforce to linkedIn,whenever i create a record to the custom object.In custom object i have a custom link after clicking on that link it should post on my LinkedIn wall.

Please,,,,,,,,, help me guysssssssssss,,,,,,,,,
Ashish_SFDCAshish_SFDC
Hi , 


There are couple of Apps, 

Free LinkedIn Integration for Salesforce

https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000B3YcTEAV

Linkedin products: 

http://www.linkedin.com/mnyfe/subscriptionv2?displaySalesProduct=&identify=false&crm=sfdc


Free LinkedIn Integration for Salesforce

http://www.ebsta.com/free-linkedin-integration-salesforce/

https://www.podbox.com/sync/#!/LinkedIn/Salesforce


Slide share by Linked in: 

http://www.slideshare.net/linkedin-sales-solutions/using-linkedin-for-salesforce-crm


Sample code: 

http://www.sundoginteractive.com/sunblog/posts/integrating-salesforce-and-linkedin


Regards,
Ashish
Salesforce@322Salesforce@322
Hi Ashish,

Thank you for the links but if u provide any sample code linkedin integration means it will be more benifitable for me and others also........................
Ashish_SFDCAshish_SFDC
Hi Keerthi, 


For Sample code to start off, 

1) Sign up for a Salesforce and LinkedIn account.
2) Sign into the LinkedIn developer account at: https://developer.linkedin.com/
3) Under your name in the upper-right corner click on ‘API Keys’
4) Click on ‘Add New Application’
5) Fill out the form and click on ‘Add Application’
6) You will get a confirmation page that includes your API Key, Secret Key, OAuth User Token and OAuth User Secret
7) One thing to note right away is that this basic LinkedIn application has limits on it for the number of calls.  If you click on the ‘VIEW API USAGE’ link you will see your daily limits.
8) Now everything is setup so that we can write the integration code for LinkedIn in Apex. 
9) The first step in the OAuth sequence is to call a LinkedIn endpoint passing your API Key and the redirect_uri among other things.  Basically, you are sending the user to LinkedIn where the user will login and then grant access to your LinkedIn application.  LinkedIn will then pass back an Authorization Code on the query string to the URL that was passed in the ‘redirect_uri’ parameter.  Here is some simple Apex code to make this call.


public PageReference newAuthorizationCode(){
    string APIKey = getMyAPIKey();  //Store the API key in a custom setting
    /*
        <a href="https://www.linkedin.com/uas/oauth2/authorization?response_type=code">https://www.linkedin.com/uas/oauth2/authorization?response_type=code</a>
                                           &client_id=YOUR_API_KEY
                                           &scope=SCOPE
                                           &state=STATE
                                           &redirect_uri=YOUR_REDIRECT_URI
        */
        
        string state = 'Anything you want returned to you'; //This state value will be passed back on redirect_uri
        string myEndPoint = '';
        string redirectPage = 'https://na6.salesforce.com/apex/LinkedInReturn';
        string scope = 'r_basicprofile r_fullprofile r_emailaddress r_network r_contactinfo rw_nus rw_groups w_messages';
        redirectPage = EncodingUtil.urlEncode(redirectPage, 'UTF-8');
        scope = EncodingUtil.urlEncode(scope, 'UTF-8');
        state = EncodingUtil.urlEncode(state, 'UTF-8');
        myEndPoint = 'https://www.linkedin.com/uas/oauth2/authorization?';
        myEndPoint += 'response_type=code';
        myEndPoint += '&client_id=' + APIKey;
        myEndPoint += '&scope=' + scope;
        myEndPoint += '&state=' + state;
        myEndPoint += '&redirect_uri=' + redirectPage;
        
        PageReference pr = new PageReference(myEndPoint);
    return pr;
}
The scope parameter is important as that specifies what access the caller should have when accessing the LinkedIn API.

10) Now you need to add code to the ‘LinkedInReturn’ Visualforce page in order to get the Authorization Code off of the URL.  The Authorization Code will come back in the ‘code’ query string so you will be able to get it like this in Apex:

myoAuthCode = ApexPages.CurrentPage().getParameters().get(‘code’);

11) Now that you have the Authorization Code you get call LinkedIn to get an Access Token.  You must POST to an endPoint that is built like this…


LinkedInEndPoint = 'https://www.linkedin.com/uas/oauth2/accessToken?' +
            'grant_type=authorization_code' +
            '&code=' + oAuthCode +
            '&redirect_uri=' + redirectPage +
            '&client_id=' + APIKey +
            '&client_secret=' + ClientSecret;
This will return some JSON that will contain your Access Token.

12) With this Access Token you can now make your calls to LinkedIn to get the data that you want.  For example, passing this type of data to the v1/people/id endpoint will return JSON data that has information about that specific user:


Http h = new Http();
HttpRequest req = new HttpRequest();
string accessToken = getAccessToken();  //This is the Access Token which we retrieved earlier.  Maybe store it in a custom setting.
req.setEndpoint('https://api.linkedin.com/v1/people/id=' + linkedInKey +
                ':(first-name,last-name,headline,location,distance,num-connections,picture-url,positions,public-profile-url)?format=json&oauth2_access_token=' + accessToken);
req.setMethod('GET');
The linkedInKey can be retrieved by using the search API calls from LinkedIn.

13) At some point this Access Token will expire so you should try to refresh it before that happens.  If you do not do this, then you will have to repeat all of the steps above to get a new Access Token.

I hope this gives you a jump-start in building your own integration with LinkedIn.

http://www.sundoginteractive.com/sunblog/posts/integrating-salesforce-and-linkedin


Regards,
Ashish
Salesforce@322Salesforce@322
Hi Ashish,

thank you for ur reply i tried this what ever u mentioned but i strucked at 10 th point.
TamilTamil
Hope this will work for you

Apex page

public class linkedinauth {
    public String x{get;set;}
    public static final string REDIRECT_URL='https://c.cs21.visual.force.com/apex/testvf';
    public static final string LINKEDIN_API_KEY='<your Linkedin API Key>';
public static final string OAUTH_CODE_END_POINT_URL='https://www.linkedin.com/uas/oauth2/authorization?response_type=code';
    public static final string SCOPE='r_basicprofile r_fullprofile r_emailaddress r_network r_contactinfo rw_nus rw_groups w_messages';
    public static final string STATE='YOUCANGIVEANYVALUE'; 
   
   public PageReference connect(){
     x=OAUTH_CODE_END_POINT_URL+'&client_id='+LINKEDIN_API_KEY+'&scope='+SCOPE+'&state='+EncodingUtil.urlEncode(STATE,'UTF-8')+'&redirect_uri='+EncodingUtil.urlEncode(REDIRECT_URL,'UTF-8');
     PageReference pageRef = new PageReference(x);
     return pageRef; 
   }
}

VF Page

<apex:page controller="linkedinauth">
<apex:form >
     <apex:commandButton value="Call Linkedin" action="{!connect}"/> 
</apex:form>
</apex:page>
dinesh kannandinesh kannan
Hi
I am also new to salesforce integration..my requirement is salesforce to linkedin integration...360 degree Built-in view to LinkedIn for client interaction..can u send me the code pls...
SS KarthickSS Karthick
Hy folks,
      I want to post a job on linkedin from salesforce.
For that I need OAuth signature but I dono how to get OAuth signature?


Please help!
TamilTamil
MalakondaiahMalakondaiah
Hi,

Could you please help me, Integrate salesforce with LinkedIn Using Webservices?