1

LinkedIn で人の公開検索を実行するために、LinkedIn ログインの認証プロセスを自動化しようとしています。

最初に、私が何をしていたかを説明しようとします。

私は4つのファイルを使用しています:

  • oAuth.php(必要)
  • linkedin.php(php LinkedIn ライブラリ)
  • auth.php(LinkedIn lib ファイルから oAuth トークンを取得します)
  • コールバック URL demo.php?params(認証が成功した後、現在のユーザーのプロファイルと params を使用した検索結果を出力します)

認証 URL はhttps://api.linkedin.com/uas/oauth/authorize?oauth_token=$oauthtoken.

私は2つのことをしましたが、どちらもうまくいかないようです。彼らです:

  1. curl を使用して、認証 URL に移動し、フィールド (ユーザー名、パスワード、oauth トークン、csrfToken、期間、sourceAlias など、Firebug から知りました) を投稿するプロセスを自動化しています。

    ここで変更されるのは、oauth トークンと csrfToken の 2 つだけです (認証 URL のコンテンツを解析することによる)。ページが読み込まれるたびに両方を取得でき、最後に curl_exec からの GET 応答を出力しようとしました。

  2. 電子メールとパスワードだけを投稿しようとして、GET 応答を印刷しようとしています。

参考までに、ここに私のものがありますauth.php

function extract_unit($string, $start, $end)
{
    $pos = stripos($string, $start);
    $str = substr($string, $pos);
    $str_two = substr($str, strlen($start));
    $second_pos = stripos($str_two, $end);
    $str_three = substr($str_two, 0, $second_pos);
    $unit = trim($str_three); // remove whitespaces
    return $unit;
}

session_start();

$config['base_url']             =   'http://linkedin.tweetrank.tk/auth.php';
$config['callback_url']         =   'http://linkedin.tweetrank.tk/demo.php';
$config['linkedin_access']      =   'my key';
$config['linkedin_secret']      =   'my secret';

include_once "linkedin.php";

# First step is to initialize with the 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;

# Now we retrieve a request token. It will be set as $linkedin->request_token
$linkedin->getRequestToken();
$_SESSION['requestToken'] = serialize($linkedin->request_token);

# With a request token in hand, we can generate an authorization URL, which
# we'll direct the user to
//echo "Authorization URL: " . $linkedin->generateAuthorizeUrl() . "\n\n";

echo $url = $linkedin->generateAuthorizeUrl();
$token = $linkedin->generateAuthorizeToken();
//echo '<br><br>';
$data = file_get_contents($url);
$csrfToken = extract_unit($data,'name="csrfToken" value="','"');

//echo $csrfToken;
//echo $token;
//echo 'https://www.linkedin.com/uas/oauth/authenticate?oauth_token='.$token.'&amp;trk=uas-continue';
// INIT CURL

$postParams = 'email=myemail&password=mypassword&duration=720&authorize=Ok%2C+I%27ll+Allow+It&extra=&access=-3&agree=true&oauth_token='.$token.'&appId=&csrfToken='.$csrfToken.'&sourceAlias=0_8L1usXMS_e_-SfuxXa1idxJ207ESR8hAXKfus4aDeAk';

ここで、認証 URL とpostParamswith curl を使用しました。

4

2 に答える 2

2

ログイン プロセスを完了するには、linkedIn Web ページの認証手順を使用する必要があります。サードパーティのアプリが資格情報を受け入れて、リンクを使用してlinkedIn認証を行うことはできませんhttps://api.linkedin.com/uas/oauth/authorize?oauth_token=$oauthtoken

于 2012-09-13T06:32:28.960 に答える
0

私はあなたが求めていることを理解していると思います.LinkedInでそれを行うことはできません. 私は最近同様の問題に直面しており、解決できませんでした。LinkedInの人たちは、データ保護などについて良い点を持っていると思います. これをチェックしてください: http://developer.linkedin.com/message/6460 http://getsatisfaction.com/linkedin/topics/cant_use_linkedin_api_to_view_public_profiles_without_oauth_login

于 2011-05-31T10:09:46.087 に答える