lscarneiro/linkedin-php-sdk

PHP LinkedIn SDK

1.1.0 2014-03-03 15:16 UTC

This package is auto-updated.

Last update: 2024-09-05 12:06:50 UTC


README

LinkedIn API 的 PHP 包装器

以下是使用此包装器快速入门的方法

实例化我们的类

$li = new LinkedIn(
  array(
    'api_key' => 'yourapikey', 
    'api_secret' => 'yourapisecret', 
    'callback_url' => 'https://yourdomain.com/redirecthere'
  )
);

获取登录 URL - 这接受一个范围数组

$url = $li->getLoginUrl(
  array(
    LinkedIn::SCOPE_BASIC_PROFILE, 
    LinkedIn::SCOPE_EMAIL_ADDRESS, 
    LinkedIn::SCOPE_NETWORK
  )
);

LinkedIn 将重定向到 'callback_url',其中 'code' 参数为访问令牌。您可能希望将令牌存储在会话中,以便用户不必再次登录

$token = $li->getAccessToken($_REQUEST['code']);
$token_expires = $li->getAccessTokenExpiration();

向 API 发送请求

$info = $li->get('/people/~:(first-name,last-name,positions)');

覆盖 curl 选项

$li = new LinkedIn(
  array(
    'api_key' => 'yourapikey', 
    'api_secret' => 'yourapisecret', 
    'callback_url' => 'https://yourdomain.com/redirecthere',
    'curl_options' => array(
        CURLOPT_PROXY => '127.0.0.1:80',
    ),
  )
);