Last active
August 29, 2015 14:11
-
-
Save muoto/ee52ef714f34400845f6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| session_start(); | |
| require_once './LinkedIn-PHP-SDK-master/linkedInAPI.php'; | |
| //company: Fingo | |
| //app name: Fingo UK | |
| //api key: 779qvypvk0ix5p | |
| //Secret Key: SGlmaPyVmaB0HVJE | |
| //OAuth User Token: 9d62e79a-b89e-414e-ad59-0ec891b86931 | |
| //OAuth User Secret: 9d670629-48ec-4da5-be48-298e411b5d71 | |
| // Change these | |
| define('API_KEY', ''); | |
| define('API_SECRET', ''); | |
| define('APP_KEY', ''); | |
| define('APP_SECRET', ''); | |
| define('CALLBACK_URL', 'http://temp.loc/'); | |
| define('SCOPE', 'r_basicprofile r_fullprofile r_emailaddress rw_nus'); | |
| $config = array( | |
| 'appKey' => API_KEY, | |
| 'appSecret' => API_SECRET, | |
| ); | |
| $linkedin = new Linkedin($config); | |
| $linkedin->setApplicationKey(APP_KEY); | |
| $linkedin->setApplicationSecret(APP_SECRET); | |
| if (!$linkedin->getUser()) { | |
| $params = array( | |
| 'callbackUrl' => CALLBACK_URL, | |
| 'scope' => SCOPE, | |
| ); | |
| $response = $linkedin->connect($params); | |
| // echo '<pre>'; var_dump($response); exit; | |
| if ($response['status'] == 'success') { | |
| $access_token = $response['access_token']; | |
| } else { | |
| echo $response['status'] . ': ' . $response['message']; | |
| die; | |
| } | |
| } | |
| //$linkedin->setAccessToken($access_token); //use this if you have a accesstoken | |
| if ($access_token) { | |
| $user = $linkedin->share($data); | |
| if ($user['info']['http_code'] == 200) { | |
| $user = json_decode($user['linkedin']); | |
| print "Hello $user->firstName $user->lastName."; | |
| } | |
| $data = array( | |
| 'comment' => 'Check out the LinkedIn Share API!', | |
| 'content' => array( | |
| 'title' => 'title', | |
| 'description' => 'description', | |
| 'submitted-url' => 'http://fingonews.com', | |
| ), | |
| 'visibility' => array( | |
| 'code' => 'anyone' | |
| ) | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment