本文整理汇总了PHP中LinkedIn类的典型用法代码示例。如果您正苦于以下问题:PHP LinkedIn类的具体用法?PHP LinkedIn怎么用?PHP LinkedIn使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LinkedIn类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: HandleResponse
function HandleResponse()
{
$config = (include "/config.php");
$li = new LinkedIn(array('api_key' => $config['linkedin_client_id'], 'api_secret' => $config['linkedin_client_secret'], 'callback_url' => $config['domain'] . "/linkedin/login/success"));
$token = $li->getAccessToken($_REQUEST['code']);
$_SESSION['linkedin_token'] = $token;
echo "<script>window.close();</script>";
die;
}
示例2: getUserIdFromApi
protected function getUserIdFromApi()
{
// Create a LinkedIn object
$linkedInApiConfig = array('appKey' => LI_API_KEY, 'appSecret' => LI_SECRET, 'callbackUrl' => APP_URL . '/' . Content::l() . '/login/linkedincallback/' . (!empty($_GET['nextPage']) ? $_GET['nextPage'] : ''));
$linkedIn = new LinkedIn($linkedInApiConfig);
try {
$response = $linkedIn->retrieveTokenAccess($_GET['oauth_token'], $_SESSION['oauth']['linkedin']['request']['oauth_token_secret'], $_GET['oauth_verifier']);
} catch (Error $e) {
Debug::l('Error. Could not retrieve LinkedIn access token. ' . $e);
header('Location: ' . APP_URL . '/' . Content::l() . '/login/linkedin/');
exit;
}
if ($response['success'] === TRUE) {
// The request went through without an error, gather user's access tokens
$_SESSION['oauth']['linkedin']['access'] = $response['linkedin'];
// Set the user as authorized for future quick reference
$_SESSION['oauth']['linkedin']['authorized'] = true;
} else {
$this->exitWithMessage('Error. The OAuth access token was not retrieved. ' . print_r($response, 1));
}
$this->accessToken = serialize($response['linkedin']);
/*
Retrieve the user ID
The XML response will look like one of these:
<person>
<id>8GhzNjjaOi</id>
</person>
<error>
<status>401</status>
<timestamp>1288518358054</timestamp>
<error-code>0</error-code>
<message>[unauthorized]. The token used in the OAuth request is not valid.</message>
</error>
*/
try {
$response = $linkedIn->profile('~:(id,first-name,last-name)');
if ($response['success'] === TRUE) {
$response['linkedin'] = new SimpleXMLElement($response['linkedin']);
if ($response['linkedin']->getName() != 'person') {
Debug::l('Error. Could not retrieve person data from LinkedIn. ' . print_r($response, 1));
header('Location: ' . APP_URL . '/' . Content::l() . '/login/linkedin/');
exit;
}
} else {
Debug::l('Error. Could not retrieve person data from LinkedIn. ' . print_r($response, 1));
header('Location: ' . APP_URL . '/' . Content::l() . '/login/linkedin/');
exit;
}
$this->linkedInId = (string) $response['linkedin']->id;
$this->name = $response['linkedin']->{'first-name'} . ' ' . $response['linkedin']->{'last-name'};
} catch (Error $e) {
Debug::l('Error. Could not retrieve person ID from LinkedIn. ' . $e);
header('Location: ' . APP_URL . '/' . Content::l() . '/login/linkedin/');
exit;
}
}
示例3: testNET_API_LinkedIn
function testNET_API_LinkedIn()
{
$LinkedIn = new LinkedIn();
$res = $LinkedIn->Login('test@test.com', 'dfgsd');
$this->assertTrue($res, "Can't login to LinkedIn");
$Profile = $LinkedIn->GetProfileByID(8418679);
//7202602);
$this->assertTrue($Profile, "Can't get LinkedIn profile");
$res = $Profile->GetPersonalDetails();
$this->assertTrue($res && count($res), "Can't get LinkedIn personal details");
$res = $Profile->GetInterests();
$this->assertTrue($res, "Can't get LinkedIn interests");
$res = $Profile->GetEmailAddress();
$this->assertTrue($res, "Can't get LinkedIn email address");
$res = $Profile->GetJobTitle();
$this->assertTrue($res, "Can't get LinkedIn job title");
$res = $Profile->GetExperience();
$this->assertTrue($res, "Can't get LinkedIn experience block");
$res = $Profile->GetEducation();
$this->assertTrue($res, "Can't get LinkedIn education block");
$connections = $LinkedIn->GetConnectionsList();
$this->assertTrue(count($connections), "No connections found");
}
示例4: getData
function getData()
{
$session = JFactory::getSession();
$post = JRequest::get('post');
$redsocialhelper = new redsocialhelper();
$login = $redsocialhelper->getsettings();
if (!isset($post['generatetoken'])) {
return JText::_('PLEASE_SELECT_SECTION');
}
switch ($post['generatetoken']) {
case 'facebook':
$fb_profile_id = $session->set('fb_profile_id', $post['fb_profile_id']);
$app_id = $login['app_id'];
$app_secret = $login['app_secret'];
require_once JPATH_SITE . '/components/com_redsocialstream/helpers/facebook/facebook.php';
$redirect_url = urlencode(JURI::base() . "index.php?option=com_redsocialstream&view=access_token");
header("location: https://www.facebook.com/dialog/oauth?client_id=" . $login['app_id'] . "&redirect_uri=" . $redirect_url . "&scope=manage_pages,publish_stream&manage_pages=1&publish_stream=1");
break;
case 'linkedin':
//Linkedin APi Key
$api_key = $login['linked_api_key'];
//Linkedin Secret Key
$secret_key = $login['linked_secret_key'];
$redirect_url = JURI::base() . "index.php?option=com_redsocialstream&view=access_token";
$linkedin_profile_id = $session->set('linkedin_profile_id', $post['linkedin_profile_id']);
$API_CONFIG = array('appKey' => $api_key, 'appSecret' => $secret_key, 'callbackUrl' => $redirect_url);
$linkedin = new LinkedIn($API_CONFIG);
$response = $linkedin->retrieveTokenRequest();
if ($response['success'] === TRUE) {
$session->set('oauthReqToken', $response['linkedin']);
// redirect the user to the LinkedIn authentication/authorisation page to initiate validation.
header('Location: ' . LINKEDIN::_URL_AUTH . $response['linkedin']['oauth_token']);
exit;
}
break;
}
}
示例5: demo
public function demo()
{
session_start();
$this->load->helper('url');
$this->load->library('linkedin');
$config['base_url'] = base_url('home/linkedin');
$config['callback_url'] = base_url('home/demo');
$config['linkedin_access'] = '75cmijp7gpecgv';
$config['linkedin_secret'] = 'CkLc98T2vkqc4vEh';
# First step is to initialize with your consumer key and secret. We'll use an out-of-band oauth_callback
$linkedin = new LinkedIn($config['linkedin_access'], $config['linkedin_secret'], $config['callback_url']);
//$linkedin->debug = true;
if (isset($_REQUEST['oauth_verifier'])) {
$_SESSION['oauth_verifier'] = $_REQUEST['oauth_verifier'];
$linkedin->request_token = unserialize($_SESSION['requestToken']);
$linkedin->oauth_verifier = $_SESSION['oauth_verifier'];
$linkedin->getAccessToken($_REQUEST['oauth_verifier']);
$_SESSION['oauth_access_token'] = serialize($linkedin->access_token);
header("Location: " . $config['callback_url']);
exit;
} else {
$linkedin->request_token = unserialize($_SESSION['requestToken']);
$linkedin->oauth_verifier = $_SESSION['oauth_verifier'];
$linkedin->access_token = unserialize($_SESSION['oauth_access_token']);
}
# You now have a $linkedin->access_token and can make calls on behalf of the current member
$xml_response = $linkedin->getProfile("~:(id,first-name,last-name,email-address,headline,picture-url)");
/* echo '<pre>';
echo 'My Profile Info';
echo $xml_response;
echo '<br />';
echo '</pre>';*/
$id = $linkedin->getProfile('~:(id)');
$email = $linkedin->getProfile('~:(email-address)');
$uid = trim(strip_tags($id));
$email_address = trim(strip_tags($email));
$response = $this->home->linkedinauth($email_address);
if ($response == 1) {
$this->home->set_online_status(1);
if ($this->session->userdata('is_login')) {
if ($this->session->userdata('is_alumni')) {
redirect(base_url('alumni'));
} elseif ($this->session->userdata('is_prospective')) {
redirect(base_url('parents'));
} else {
redirect(base_url('seeker'));
}
}
} else {
redirect(base_url('home'));
}
$this->data['view_file'] = 'index';
echo Modules::run('template/home', $this->data);
}
示例6: get_resume_data
function get_resume_data()
{
$this->_check_auth();
$API_CONFIG = $this->config->item('LINKEDIN_KEYS');
$OBJ_linkedin = new LinkedIn($API_CONFIG);
$OBJ_linkedin->setTokenAccess($this->session->userdata('access'));
$OBJ_linkedin->setResponseFormat(LINKEDIN::_RESPONSE_JSON);
$resumeResponse = $OBJ_linkedin->profile('~:(first-name,last-name,formatted-name,industry,skills,summary,specialties,positions,picture-url,educations,interests,headline,phone-numbers,email-address,member-url-resources)');
if ($resumeResponse['success'] === TRUE) {
$resumeData = json_decode($resumeResponse['linkedin'], true);
//print_r($resumeData);
$this->load->model('resume');
$userId = $this->session->userdata('user_id');
$resumeData = array();
$resumeData['user_id'] = $userId;
$resumeData['json_data'] = $resumeResponse['linkedin'];
$resumeData['update_date'] = date('Y-m-d h:i:s');
if (!$this->resume->exist($userId)) {
$resumeData['create_date'] = date('Y-m-d h:i:s');
$resumeId = $this->resume->create($resumeData);
} else {
$resumeId = $this->resume->update_user_id($userId, $resumeData);
}
redirect('/builder/customize/' . $resumeId, 'refresh');
}
}
示例7: getAPI
protected function getAPI()
{
$OAuth2 = nxcSocialNetworksOAuth2::getInstanceByType('linkedin');
$OAuth2Token = $OAuth2->getToken();
$API = new LinkedIn(array('appKey' => $OAuth2->appSettings['key'], 'appSecret' => $OAuth2->appSettings['secret'], 'callbackUrl' => null));
$API->setTokenAccess(array('oauth_token' => $OAuth2Token->attribute('token'), 'oauth_token_secret' => $OAuth2Token->attribute('secret')));
return $API;
}
示例8: sfsi_getlinkedin_follower
function sfsi_getlinkedin_follower($ln_company, $APIsettings)
{
require_once SFSI_DOCROOT . '/helpers/linkedin-api/linkedin-api.php';
$url = 'http' . (empty($_SERVER['HTTPS']) ? '' : 's') . '://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$linkedin = new LinkedIn($APIsettings['ln_api_key'], $APIsettings['ln_secret_key'], $APIsettings['ln_oAuth_user_token'], $url);
$followers = $linkedin->getCompanyFollowersByName($ln_company);
return strip_tags($followers);
}
示例9: sfsi_getlinkedin_follower
function sfsi_getlinkedin_follower($ln_company, $APIsettings)
{
require_once SFSI_DOCROOT . '/helpers/linkedin-api/linkedin-api.php';
$scheme = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https" : "http";
$url = $scheme . '://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$linkedin = new LinkedIn($APIsettings['ln_api_key'], $APIsettings['ln_secret_key'], $APIsettings['ln_oAuth_user_token'], $url);
$followers = $linkedin->getCompanyFollowersByName($ln_company);
return strip_tags($followers);
}
示例10: onSloginCheck
public function onSloginCheck()
{
$redirect = JURI::base() . '?option=com_slogin&task=check&plugin=linkedin';
$app = JFactory::getApplication();
$input = $app->input;
$oauth_problem = $input->getString('oauth_problem', '');
if ($oauth_problem == 'user_refused') {
$config = JComponentHelper::getParams('com_slogin');
JModel::addIncludePath(JPATH_ROOT . '/components/com_slogin/models');
$model = JModel::getInstance('Linking_user', 'SloginModel');
$redirect = base64_decode($model->getReturnURL($config, 'failure_redirect'));
$controller = JControllerLegacy::getInstance('SLogin');
$controller->displayRedirect($redirect, true);
}
# First step is to initialize with your consumer key and secret. We'll use an out-of-band oauth_callback
$linkedin = new LinkedIn($this->params->get('api_key'), $this->params->get('secret_key'), $redirect);
//$linkedin->debug = true;
$oauth_verifier = $input->getString('oauth_verifier', '');
$requestToken = unserialize($app->getUserState('requestToken'));
$linkedin->request_token = $requestToken;
$linkedin->oauth_verifier = $app->getUserState('oauth_verifier');
if (!empty($oauth_verifier)) {
$app->setUserState('oauth_verifier', $oauth_verifier);
$linkedin->getAccessToken($oauth_verifier);
$app->setUserState('oauth_access_token', serialize($linkedin->access_token));
header("Location: " . $redirect);
exit;
} else {
$linkedin->access_token = unserialize($app->getUserState('oauth_access_token'));
}
# You now have a $linkedin->access_token and can make calls on behalf of the current member
//$request = $linkedin->getProfile("~:(id,first-name,last-name,headline,picture-url)");
$request = $linkedin->getProfile("~:(id,first-name,last-name,headline,picture-url,email-address)?format=json");
$request = json_decode($request);
if (empty($request)) {
echo 'Error - empty user data';
exit;
} else {
if (!empty($request->errorCode)) {
echo 'Error - ' . $request->message;
exit;
}
}
$returnRequest = new SloginRequest();
$returnRequest->first_name = $request->firstName;
$returnRequest->last_name = $request->lastName;
// $returnRequest->email = $request->email;
$returnRequest->id = $request->id;
$returnRequest->real_name = $request->firstName . ' ' . $request->lastName;
$returnRequest->display_name = $request->firstName;
$returnRequest->all_request = $request;
return $returnRequest;
}
示例11: Share
function Share()
{
$config = (include "/config.php");
$li = new LinkedIn(array('api_key' => $config['linkedin_client_id'], 'api_secret' => $config['linkedin_client_secret'], 'callback_url' => $config['domain'] . "/linkedin/login/success"));
$li->setAccessToken($_SESSION['linkedin_token']);
$li->setState($_SESSION['linkedin_state']);
$hasParams = false;
$comment = "";
$title = "";
$description = "";
$url = "";
$source = "";
$visiblity = "";
if (isset($_POST['title']) && $_POST['title'] != "") {
$hasParams = true;
$title = $_POST['title'];
}
if (isset($_POST['description']) && $_POST['description'] != "") {
$hasParams = true;
$description = $_POST['description'];
}
if (isset($_POST['url']) && $_POST['url'] != "") {
$hasParams = true;
$url = $_POST['url'];
}
if (isset($_POST['source']) && $_POST['source'] != "") {
$hasParams = true;
$source = $_POST['source'];
}
if (isset($_POST['comment']) && $_POST['comment'] != "") {
$comment = $_POST['comment'];
}
if (isset($_POST['visiblity']) && $_POST['visiblity'] != "") {
$visiblity = $_POST['visiblity'];
} else {
$visiblity = "anyone";
}
if (!$hasParams) {
return "Missing params";
exit;
}
$post = array('comment' => $comment, 'content' => array('title' => $title, 'description' => $description, 'submitted_url' => $url, 'submitted_image_url' => $source), 'visibility' => array('code' => $visiblity));
//echo $li->getAccessToken();
try {
$li->post('/people/~/shares', $post);
} catch (Exception $ex) {
return $ex->getMessage();
}
return 'success';
}
示例12: _startLinkedinHandshake
private function _startLinkedinHandshake($req_type, $credentials)
{
$session = self::oauth_session_exists();
$app = JFactory::getApplication();
require_once dirname(__FILE__) . DS . 'jobboard' . DS . 'lib' . DS . 'linkedin' . DS . 'linkedin_3.1.1.class.php';
$API_CONFIG = array('appKey' => $credentials['key'], 'appSecret' => $credentials['secret'], 'callbackUrl' => null);
switch ($req_type) {
case 'initiate':
$API_CONFIG['callbackUrl'] = JURI::root() . 'index.php?option=com_jobboard&view=user&task=getlinkedinprof&' . $req_type . '=initiate&' . LINKEDIN::_GET_RESPONSE . '=1&Itemid=' . $this->_itemid;
$OBJ_linkedin = new LinkedIn($API_CONFIG);
$_GET[LINKEDIN::_GET_RESPONSE] = isset($_GET[LINKEDIN::_GET_RESPONSE]) ? $_GET[LINKEDIN::_GET_RESPONSE] : '';
if (!$_GET[LINKEDIN::_GET_RESPONSE]) {
$response = $OBJ_linkedin->retrieveTokenRequest();
if ($response['success'] === TRUE) {
$session_oauth = $session->get('oauth');
$session_oauth['oauth']['linkedin']['request'] = $response['linkedin'];
$session->set('oauth', $session_oauth);
$app->redirect(LINKEDIN::_URL_AUTH . $response['linkedin']['oauth_token']);
} else {
$msg = JText::_('PLG_JOBBOARD_REQUEST_TOKEN_RETRIEVAL_FAILED');
$app->redirect('index.php?option=com_jobboard&view=user&task=addcv&Itemid=' . $this->_itemid, $msg, 'error');
}
} else {
self::_processResponse(&$OBJ_linkedin);
}
return self::_getLinkedInProfile(&$OBJ_linkedin);
break;
case 'revoke':
$session_oauth = $session->get('oauth');
$OBJ_linkedin = new LinkedIn($API_CONFIG);
$OBJ_linkedin->setTokenAccess($session_oauth['oauth']['linkedin']['access']);
$response = $OBJ_linkedin->revoke();
if ($response['success'] === TRUE) {
if ($session->clear('oauth')) {
$msg = JText::_('PLG_JOBBOARD_AUTH_REVOKE_SUCCESS');
$msg_type = 'Message';
} else {
$msg = JText::_('PLG_JOBBOARD_SESSION_CLEAR_FAILED');
$msg_type = 'error';
}
} else {
$msg = JText::_('PLG_JOBBOARD_AUTH_REVOKE_FAILED');
$msg_type = 'error';
}
$app->redirect('index.php?option=com_jobboard&view=user&task=addcv&Itemid=' . $this->_itemid, $msg, $msg_type);
break;
default:
break;
}
}
示例13: loadProfiles
private function loadProfiles($person, $personIsUser)
{
$profiles = array();
if (!empty($person['facebook_access_token']) && (!$personIsUser || $this->mergeNetwork != 'Facebook')) {
try {
//$params = array('access_token' => $user['facebook_access_token']);
$facebookProfile = SessionManager::getInstance()->getFacebook()->api('/' . $person['facebook_id']);
} catch (FacebookApiException $e) {
Debug::l('Error loading Facebook profile for ' . ($personIsUser ? 'current' : 'other') . ' user. ' . $e);
}
if (isset($facebookProfile)) {
$profiles[] = '<a href="' . $facebookProfile['link'] . '" target="_blank" class="profile"><img src="https://graph.facebook.com/' . $person['facebook_id'] . '/picture?type=square" /> ' . $facebookProfile['name'] . ' on Facebook</a>';
}
}
if (!empty($person['linkedin_access_token']) && (!$personIsUser || $this->mergeNetwork != 'LinkedIn')) {
$API_CONFIG = array('appKey' => LI_API_KEY, 'appSecret' => LI_SECRET, 'callbackUrl' => '');
$OBJ_linkedin = new LinkedIn($API_CONFIG);
$OBJ_linkedin->setTokenAccess(unserialize($person['linkedin_access_token']));
try {
$linkedInProfile = $OBJ_linkedin->profile('id=' . $person['linkedin_id'] . ':(first-name,last-name,public-profile-url,picture-url)');
} catch (ErrorException $e) {
Debug::l('Error loading LinkedIn profile for ' . ($personIsUser ? 'current' : 'other') . ' user. ' . $e);
}
if ($linkedInProfile['success'] === TRUE) {
$linkedInProfile['linkedin'] = new SimpleXMLElement($linkedInProfile['linkedin']);
if ($linkedInProfile['linkedin']->getName() == 'person') {
$li_pr = (string) $linkedInProfile['linkedin']->{'public-profile-url'};
$li_pi = (string) $linkedInProfile['linkedin']->{'picture-url'};
$li_fn = (string) $linkedInProfile['linkedin']->{'first-name'};
$li_ln = (string) $linkedInProfile['linkedin']->{'last-name'};
$profiles[] = '<a href="' . $li_pr . '" target="_blank" class="profile"><img src="' . $li_pi . '" /> ' . $li_fn . ' ' . $li_ln . ' on LinkedIn</a>';
}
}
}
if (!empty($person['twitter_access_token']) && ($personIsUser || $this->mergeNetwork != 'Twitter')) {
try {
$twitterAccessToken = unserialize($person['twitter_access_token']);
$twitter = new TwitterOAuth(TW_CONSUMER, TW_SECRET, $twitterAccessToken['oauth_token'], $twitterAccessToken['oauth_token_secret']);
$twitter->format = 'json';
$twitterProfile = $twitter->get('users/show', array('user_id' => $person['twitter_id']));
} catch (ErrorException $e) {
Debug::l('Error loading Twitter profile for ' . ($personIsUser ? 'current' : 'other') . ' user. ' . $e);
}
if (isset($twitterProfile)) {
$profiles[] = '<a href="http://twitter.com/' . $twitterProfile->screen_name . '" target="_blank" class="profile"><img src="' . $twitterProfile->profile_image_url . '" /> @' . $twitterProfile->screen_name . ' on Twitter</a>';
}
}
return $profiles;
}
示例14: linkedinGetLoggedinUserInfo
public function linkedinGetLoggedinUserInfo($requestToken = '', $oauthVerifier = '', $accessToken = '')
{
include_once $this->config['linkedin_library_path'];
$linkedin = new LinkedIn($this->config['linkedin_access'], $this->config['linkedin_secret']);
$linkedin->request_token = unserialize($requestToken);
//as data is passed here serialized form
$linkedin->oauth_verifier = $oauthVerifier;
$linkedin->access_token = unserialize($accessToken);
try {
$xml_response = $linkedin->getProfile("~:(id,first-name,last-name,headline,picture-url,public-profile-url)");
} catch (Exception $o) {
print_r($o);
}
return $xml_response;
}
开发者ID:BGCX067,项目名称:facebook-twitter-linkedin-status-update-svn-to-git,代码行数:15,代码来源:class.fblinkedtwit.php
示例15: linkedInStatus
public function linkedInStatus($status, $requestToken = '', $oauthVerifier = '', $accessToken = '')
{
include_once 'linkedinoAuth.php';
$linkedin = new LinkedIn($this->config['linkedin_access'], $this->config['linkedin_secret']);
$linkedin->request_token = unserialize($requestToken);
//as data is passed here serialized form
$linkedin->oauth_verifier = $oauthVerifier;
$linkedin->access_token = unserialize($accessToken);
try {
$xml_response = $linkedin->setStatus($status);
} catch (Exception $o) {
print_r($o);
}
return $xml_response;
}