<?php
/**
* This file defines the 'LinkedIn' class. This class is designed to be a
* simple, stand-alone implementation of the LinkedIn API functions.
*
* COPYRIGHT:
*
* Copyright (C) 2011, fiftyMission Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* SOURCE CODE LOCATION:
*
* http://code.google.com/p/simple-linkedinphp/
*
* REQUIREMENTS:
*
* 1. You must have cURL installed on the server and available to PHP.
* 2. You must be running PHP 5+.
*
* QUICK START:
*
* There are two files needed to enable LinkedIn API functionality from PHP; the
* stand-alone OAuth library, and this LinkedIn class. The latest version of
* the stand-alone OAuth library can be found on Google Code:
*
* http://code.google.com/p/oauth/
*
* Install these two files on your server in a location that is accessible to
* the scripts you wish to use them in. Make sure to change the file
* permissions such that your web server can read the files.
*
* Next, make sure the path to the OAuth library is correct (you can change this
* as needed, depending on your file organization scheme, etc).
*
* Finally, test the class by attempting to connect to LinkedIn using the
* associated demo.php page, also located at the Google Code location
* referenced above.
*
* RESOURCES:
*
* REST API Documentation: http://developer.linkedin.com/rest
*
* @version 3.3.0 - December 10, 2011
* @author Paul Mennega <paul@fiftymission.net>
* @copyright Copyright 2011, fiftyMission Inc.
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Source: http://code.google.com/p/oauth/
*
* Rename and move as needed, changing the require_once() call to the correct
* name and path.
*/
if(!extension_loaded('oauth')) {
// the PECL OAuth extension is not present, load our third-party OAuth library
require_once('OAuth.php');
} else {
// the PECL extension is present, which is not compatible with this library
throw new LinkedInException('Simple-LinkedIn: library not compatible with installed PECL OAuth extension. Please disable this extension to use the Simple-LinkedIn library.');
}
/**
* 'LinkedInException' class declaration.
*
* This class extends the base 'Exception' class.
*
* @access public
* @package classpackage
*/
class LinkedInException extends Exception {}
/**
* 'LinkedIn' class declaration.
*
* This class provides generalized LinkedIn oauth functionality.
*
* @access public
* @package classpackage
*/
class LinkedIn {
// api/oauth settings
const _DEFAULT_OAUTH_REALM = 'http://api.linkedin.com';
const _DEFAULT_OAUTH_VERSION = '1.0';
// the default response format from LinkedIn
const _DEFAULT_RESPONSE_FORMAT = 'xml';
// helper constants used to standardize LinkedIn <-> API communication. See demo page for usage.
const _GET_RESPONSE = 'lResponse';
const _GET_TYPE = 'lType';
// Invitation API constants.
const _INV_SUBJECT = 'Invitation to connect';
const _INV_BODY_LENGTH = 200;
// API methods
const _METHOD_TOKENS = 'POST';
// Network API constants.
const _NETWORK_LENGTH = 1000;
const _NETWORK_HTML = '<a>';
// response format type constants, see http://developer.linkedin.com/docs/DOC-1203
const _RESPONSE_JSON = 'JSON';
const _RESPONSE_JSONP = 'JSONP';
const _RESPONSE_XML = 'XML';
// Share API constants
const _SHARE_COMMENT_LENGTH = 700;
const _SHARE_CONTENT_TITLE_LENGTH = 200;
const _SHARE_CONTENT_DESC_LENGTH = 400;
// LinkedIn API end-points
const _URL_ACCESS = 'https://api.linkedin.com/uas/oauth/accessToken';
const _URL_API = 'https://api.linkedin.com';
/**
* @deprecated
*/
const _URL_AUTH = self::_URL_AUTHENTICATE;
const _URL_AUTHENTICATE = 'https://www.linkedin.com/uas/oauth/authenticate?oauth_token=';
const _URL_AUTHORIZE = 'https://www.linkedin.com/uas/oauth/authorize?oauth_token=';
const _URL_REQUEST = 'https://api.linkedin.com/uas/oauth/requestToken';
const _URL_REVOKE = 'https://api.linkedin.com/uas/oauth/invalidateToken';
// library version
const _VERSION = '3.3.0';
// oauth properties
protected $callback;
protected $token = NULL;
// application properties
protected $application_key,
$application_secret;
// the format of the data to return
protected $response_format = self::_DEFAULT_RESPONSE_FORMAT;
// last request fields
public $last_request_headers,
$last_request_url;
/**
* Create a LinkedIn object, used for OAuth-based authentication and
* communication with the LinkedIn API.
*
* @param arr $config
* The 'start-up' object properties:
* - appKey => The application's API key
* - appSecret => The application's secret key
* - callbackUrl => [OPTIONAL] the callback URL - only used to
* retrieve the request token.
*
* @return obj
* A new LinkedIn object.
*/
public function __construct($config) {
if(!is_array($config)) {
// bad data passed
throw new LinkedInException('LinkedIn->__construct(): bad data passed, $config must be of type array.');
}
$this->setApplicationKey($config['appKey']);
$this->setApplicationSecret($config['appSecret']);
if(array_key_exists('callbackUrl', $config)) {
$this->setCallbackUrl($config['callbackUrl']);
} else {
$this->setCallbackUrl(NULL);
}
}
/**
* The class destructor.
*
* Explicitly clears LinkedIn object from memory upon destruction.
*/
public function __destruct() {
unset($this);
}
/**
* Bookmark a job.
*
* Calling this method causes the current user to add a bookmark for the
* specified job:
*
* http://developer.linkedin.com/docs/DOC-1323
*
* @param str $jid
* Job ID you want to bookmark.
*
* @return arr
* Array containing retrieval success, LinkedIn response.
*
* @since 3.1.0
*/
public function bookmarkJob($jid) {
// check passed data
if(!is_string($jid)) {
// bad data passed
throw new LinkedInException('LinkedIn->bookmarkJob(): bad data passed, $jid must be of type string.');
}
// construct and send the request
$query = self::_URL_API . '/v1/people/~/job-bookmarks';
$response = $this->fetch('POST', $query, '<job-bookmark><job><id>' . trim($jid) . '</id></job></job-bookmark>');
/**
* Check for successful request (a 201 response from LinkedIn server)
* per the documentation linked in m
没有合适的资源?快使用搜索试试~ 我知道了~
linkedin api for php
共16个文件
php:12个
png:1个
html:1个
3星 · 超过75%的资源 需积分: 10 16 下载量 175 浏览量
2013-08-09
14:57:09
上传
评论
收藏 88KB ZIP 举报
温馨提示
linkedin api for php 有相关的文档 网址参考,不过普片上只要你流程没错,代码只要把key secret放进去 程序就哦了 就收个1积分吧 这不自己也没积分了
资源推荐
资源详情
资源评论
收起资源包目录
linkedin.zip (16个子文件)
linkedin
demo
jobs.php 21KB
network.php 34KB
test.php 3KB
index.php 17KB
1.png 12KB
groups111.php 34KB
phpinfo.php 93B
exchange
tokenExchange.html 7KB
tokenExchange.php 6KB
jobsPosting.php 23KB
company.php 22KB
content.php 18KB
test.php.bak 3KB
linkedin使用说明.wps 11KB
linkedin_3.3.0.class.php 100KB
OAuth.php 27KB
共 16 条
- 1
资源评论
- gn_zhu2014-05-17不是很好用
uinit01
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功