我試圖登錄到使用PHP +捲曲的Twitter,但我覺得有些不對勁符合我的要求,因爲我得到這個作爲迴應:登錄到Twitter的,捲曲
東西是技術上的錯誤。
感謝您的注意 - 我們將會修復它,讓事情很快回到 。
我使用的PHP代碼是:
<?php
$ch = curl_init($sTarget);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $sPost);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, $_CKS);
curl_setopt($ch, CURLOPT_COOKIEFILE, $_CKS);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: multipart/form-data"));
curl_setopt($ch, CURLOPT_REFERER, "https://twitter.com");
?>
$ sPost看起來是這樣的:
會議[username_or_email] =用戶&會話[密碼] =密碼& remember_me = 1 & scribe_log = & redirect_after_login = & authenticity_token = 6e706165609354bd7a92a99cf94e09140ea86c6f
該代碼首先獲取登錄表單字段,以便post變量具有適當的值(auth token)。我只是嘗試了一切,是的,我知道這有一個API,但我寧願找出如何做到手動學習的緣故。
在此先感謝。
我將如何去保持用戶使用此登錄?該腳本用於登錄用戶,但會話不會保留。 – Zy0n 2014-01-24 12:20:39
您將使用CURLOPT_COOKIEJAR獲取存儲在文件中的cookie,以便在隨後的請求中重新使用它們。 – 2015-12-23 12:21:26