+ Start a Discussion
satheesh8.k1.3890099515516848E12satheesh8.k1.3890099515516848E12 

salesforce integration with linkedin

Hi All,

Please help me,
I got the information from linkedin and display it in VF page. but i want store those information in one custom object.

how to do this one ,
please find attached screenshot, here  first page block shows I fetched linkedin information,
second page block i created two custom fields in one custom object.

here there is no relationship between custom fields and linkedin field , please help me how to make relation or how to update custom fields with linkedin information . 

User-added image
Thanks
Satheesh
Best Answer chosen by satheesh8.k1.3890099515516848E12
viruSviruS
Hi Sateesh,

No Need to create input fields on Vf Page .. your save method would be 

public void saveList(){

        LinkedIN__c salesObjInst = new LinkedIN__c(); //  Either salesObj is standard or custom object

        salesObjInst.FirstName__c =  ww.firstName;  // Field Assignment
        salesObjInst.HeadLine__c =  ww.headline;  // Field Assignment

        insert  salesObjInst; // DML Operations

      }

All Answers

viruSviruS
Hi Satheesh,

Where you are recieving linked in information .. on Controller /  Apex Class / Or Vf page .. ?   Acocrdingly we can decide what approach should be use 
satheesh8.k1.3890099515516848E12satheesh8.k1.3890099515516848E12
HI virus

Please find below code:
Apex Code:

public with sharing class linkedinController123 {

    public linkedinController123(ApexPages.StandardController controller) {

    }
    public String Click { get; set; }
    public String authCode {get;set;}
    public string Body {get;set;}
    public string responseBody {get;set;}
    public String authorizationCodeURI{get;set;}
    public fromJSON ww {set;get;}
  //  public positions  ww1 {set;get;}    
    public class fromJSON
    {
     // json coverted into apex
    }   
    Public void doAction()
    {
    authCode = apexPages.currentPage().getParameters().get('code');
    Click = 'https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=22222222&state=Mytesting&redirect_uri=https://c.ap1.visual.force.com/apex/NewLinkedINTest';
    system.debug('@@@@@@@@@@@@'+authCode);
    HttpResponse hr;
     
    if (authCode != null){
    Http hp = new Http();
    HttpRequest hrqToken = new HttpRequest ();
    hrqToken.setEndpoint('https://www.linkedin.com/uas/oauth2/accessToken?grant_type=authorization_code&code='+authCode+'&redirect_uri=https://c.ap1.visual.force.com/apex/NewLinkedINTest&client_id=2222222222&client_secret=3333333333333');
    hrqToken.setMethod('POST');
    hrqToken.setTimeout(60*1000);
    hr=hp.send(hrqToken);
    Body = hr.getBody();
    system.debug('The Respose-------------'+Body);
    
    JSONWrapper jsonWrapObj = (JSONWrapper)JSON.deserialize(body, JSONWrapper.class);
    
    Http h=new Http();
             List<String> orgInfo=new List<String>();
             HttpRequest req = new HttpRequest();
             req.setendpoint('https://api.linkedin.com/v1/people/~:(id,first-name,last-name,headline,picture-url,industry,summary,specialties,positions:(id,title,summary,start-date,end-date,is-current,company:(id,name,type,size,industry,ticker)),educations:(id,school-name,field-of-study,start-date,end-date,degree,activities,notes),associations,interests,num-recommenders,date-of-birth,publications:(id,title,publisher:(name),authors:(id,name),date,url,summary),patents:(id,title,summary,number,status:(id,name),office:(name),inventors:(id,name),date,url),languages:(id,language:(name),proficiency:(level,name)),skills:(id,skill:(name)),certifications:(id,name,authority:(name),number,start-date,end-date),courses:(id,name,number),recommendations-received:(id,recommendation-type,recommendation-text,recommender),honors-awards,three-current-positions,three-past-positions,volunteer)?format=json&oauth2_access_token='+jsonWrapObj.access_token );
             req.setMethod('GET');
             //req.setHeader('Content-Type','application/xml');
             HttpResponse res = h.send(req);
             responseBody = res.getBody();
             string jsonStr= responseBody ;
             JSONParser parser = JSON.createParser(jsonStr);
             system.debug('The required data+++++++++++++++++++++++++++++++++'+parser );
            while (parser.nextToken() != null) 
            {
                // integer i =0;
                if (parser.getCurrentToken() == JSONToken.START_OBJECT) 
                {
                    ww = ( fromJSON)parser.readValueAs(fromJSON.class);                 
                }
            }//while closed    
     } // if condition 
     }// do Action
    
    public class JSONWrapper{
         
        public Integer expires_in;
        public String access_token;
 
  }
  
  
  // assignment
     public String firstName{get;set;} // input text1 value  from vf
     public String headline{get;set;} // input text2 value  from vf

      public void saveList(){

        LinkedIN__c salesObjInst = new LinkedIN__c(); //  Either salesObj is standard or custom object

        salesObjInst.FirstName__c =  firstName;  // Field Assignment
        salesObjInst.HeadLine__c =  headline;  // Field Assignment

        insert  salesObjInst; // DML Operations

      }

}

VF :

<apex:page standardController="LinkedIN__c" extensions="linkedinController123" action="{!doAction}">
<!--<apex:page controller="linkedinController123"  action="{!doAction}"> -->
  <apex:form >
  <apex:outputlink value="{!Click }"> Click Me
   </apex:outputLink> 
   <div>responseBody:{!responseBody }</div>
 <!-- <apex:outputLink value="{!authorizationCodeURI}">Authorize Me</apex:outputLink> -->
  <!--<div>Body:{!Body}</div>
   <div>responseBody:{!responseBody }</div>
   --> 
   <apex:pageBlock >
       <apex:pageBlockTable value="{!ww}" var="a">
           <apex:column headerValue="FirstName" value="{!a.firstName}" />
           <apex:column headerValue="Headline" value="{!a.headline}" />
           <apex:column headerValue="Industry" value="{!a.industry}" />
           <apex:column headerValue="LastName" value="{!a.lastName}" />              
       </apex:pageBlockTable>
   </apex:pageBlock>
   <apex:pageBlock >
       <apex:pageBlockSection >
           <apex:pageBlockSectionItem >
                    <apex:outputLabel value="FirstName" for="sa1"/>
                    <apex:inputText value="{!firstName}" id="sa1"/> 
           </apex:pageBlockSectionItem>         
        <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Headline" for="sa"/>
                    <apex:inputText value="{!headline}" id="sa"/> 
        </apex:pageBlockSectionItem>
        
        </apex:pageBlockSection>
    <apex:commandButton value="save" action="{!saveList}"/>
   </apex:pageBlock>
   
 </apex:form>
</apex:page>


Please help me 

Thanks
Satheesh
viruSviruS
Hi Sateesh,

No Need to create input fields on Vf Page .. your save method would be 

public void saveList(){

        LinkedIN__c salesObjInst = new LinkedIN__c(); //  Either salesObj is standard or custom object

        salesObjInst.FirstName__c =  ww.firstName;  // Field Assignment
        salesObjInst.HeadLine__c =  ww.headline;  // Field Assignment

        insert  salesObjInst; // DML Operations

      }
This was selected as the best answer
satheesh8.k1.3890099515516848E12satheesh8.k1.3890099515516848E12
Hi Virus,

Thanks you very much,

Thanks
Satheesh
satheesh8.k1.3890099515516848E12satheesh8.k1.3890099515516848E12
Hi Virus,

please help me ,

I want post some information from salesforce to linkedin  and vice versa,

do you have any code regarding this or guide me

Thanks
Satheesh
viruSviruS
What information do you need to submit and get ?   i am on skype  virendrasinghanruka
viruSviruS
Id >> virendrasinghnaruka .. 
satheesh8.k1.3890099515516848E12satheesh8.k1.3890099515516848E12
Hi Virus,

Sorry i am in office , I cann't connect now.
User-added image

above screen shot shows two labels or fields in linkedin , I want update this information from salesforce 

Please help me 
Thanks
Satheesh