Jump to content

capson

New Members
  • Posts

    1
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

capson's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello, I am very new to php, I have some ability with vba but of no help with this project. I am trying to help a small nonprofit with a Linkedin project. I found this code here it does a part of what I need, it collects the authentication token from the first user that gives permission to do so. The problem is it only collects the first user authentication token and I need it to collect all users authentication tokens. Thanks for any help <?php /** * This is just for illustrative purposes. Ideally should be a user object and based on a real database */ class TokenDB { static $file = 'token.storage'; public static function getToken(){ return @file_get_contents(TokenDB::$file); } public static function setToken($t){ file_put_contents(TokenDB::$file,$t); } public static function resetToken(){ file_put_contents(TokenDB::$file,''); } } include '../simplelinkedin.class.php'; //Set up the API $ln = new SimpleLinkedIn('xxxx', 'yyyy'); //Set the current consumer token as the one stored in our DB. $ln->setTokenData(TokenDB::getToken()); if($ln->authorize()){ try { //Do some OAuth requests... $user = $ln->fetch('GET', '/v1/people/~:(firstName,lastName)'); print "Hello $user->firstName $user->lastName."; //Update stored token. $tokenData = $ln->getTokenData(); TokenDB::setToken($tokenData['access_token']); } catch(SimpleLinkedInException $e){ //If token was expired or invalid, we reset and reauthorize. if($e->getLastResponse()->status == 401){ //reset the stored token, so we can go through the authorization process //again at page refresh TokenDB::resetToken(); //Reauthorize.. $ln->authorize(); exit; } else throw $e; } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.