我嘗試模擬LinkedIn Web瀏覽器(PHP)的授權。我使用Guzzle Http Client。Guzzle Http客戶端和LinkedIn上的授權
下面是授權碼的一部分:
use GuzzleHttp\Client as LinkedinClient;
use PHPHtmlParser\Dom as Parser;
public function authLinkedin()
{
$client = new LinkedinClient(['base_url' => 'https://www.linkedin.com']);
try {
$postData = [
'session_key' => 'My_email',
'session_password' => 'My_password',
'action' => 'login'
];
$request = $client->createRequest('POST', '/uas/login', ['body' => $postData, 'cookies' => true]);
$response = $client->send($request);
if ($response->getStatusCode() === 200) {
$parser = new Parser();
$parser->load($client->get('https://www.linkedin.com/', ['cookies' => true])->getBody());
return $parser;
} else {
Log::store("Authorization error", Log::TYPE_ERROR, $request->getStatusCode());
return null;
}
return $request;
} catch (Exception $ex) {
Log::store("Failure get followers", Log::TYPE_ERROR, $ex->getMessage());
return null;
}
}
請求成功,返回一個200碼,但我並沒有授權。誰可以面對類似的任務,或者在代碼中漏掉了什麼。我將不勝感激任何建議。
完整訊息數據演示:session_key可以=測試%40gmail.com&session_password = asdasdasdasd&isJsEnabled =假loginCsrfParam = 252be5bc-6822-4020-8a80-439a809f8f73 &sourceAlias = 0_7r5yezRXCiA_H0CRD8sf6DhOjTKUNps5xGTqeX8EEoi&提交=登錄+中....你丟失了太多的東西。 xD –