Exemple #1
0
 /**
  * Function to get LinkedIn Authorize URL and access token
  */
 function fnLinkedInConnect()
 {
     # Object of class
     $ObjLinkedIn = new SMAPLinkedInOAuth2();
     $strApiKey = $this->api_key;
     $strSecreteKey = $this->api_secret;
     //put here your redirect url
     $strRedirect_url = $this->api_callback;
     $strCode = isset($_REQUEST['code']) ? $_REQUEST['code'] : '';
     if ($strCode == "") {
         try {
             # Get LinkedIn Authorize URL
             #If the user authorizes your application they will be redirected to the redirect_uri that you specified in your request .
             $strGetAuthUrl = $ObjLinkedIn->getAuthorizeUrl($strApiKey, $strRedirect_url);
         } catch (Exception $e) {
         }
         header("Location: " . $strGetAuthUrl);
         exit;
     }
     # Get LinkedIn Access Token
     /**
      * Access token is unique to a user and an API Key. You need access tokens in order to make API calls to LinkedIn on behalf of the user who authorized your application.
      * The value of parameter expires_in is the number of seconds from now that this access_token will expire in (5184000 seconds is 60 days).
      * You should have a mechanism in your code to refresh the tokens before they expire in order to continue using the same access tokens.
      */
     $arrAccess_token = $ObjLinkedIn->getAccessToken($strApiKey, $strSecreteKey, $strRedirect_url, $strCode);
     $strAccess_token = $arrAccess_token["access_token"];
     $this->api_acc_token = $strAccess_token;
 }