0
私はウェブサイトhttp://www.discogs.comにPHPスクリプトとcURLを使用してログインしようとしています。PHPカール(またはその他)を使用してDiscogs.comにログインするには?
https://www.discogs.com/sell/mywants?ev=wsimからデータを取得する必要があります。これは、アイテムを希望リストに追加したオファーのリストです。私が見つけたものから、このリストはAPIでは利用できません。
標準のcURLリクエストを使用してログインする際に問題があります。私のコードは次のとおりです。
$username = 'myuser';
$password = 'mypassword';
$loginUrl = 'https://www.discogs.com/login';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $loginUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'username='.urlencode($username).'&password='.urlencode($password));
curl_setopt($ch, CURLOPT_COOKIEJAR, 'c:\cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'c:\tmp.txt');
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/32.0.1700.107 Chrome/32.0.1700.107 Safari/537.36');
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch);
if (curl_error($ch)) {
echo curl_error($ch);
return;
} else {
echo "OK";
}
curl_setopt($ch, CURLOPT_URL, 'https://www.discogs.com/sell/mywants?ev=wsim');
$content = curl_exec($ch);
echo $content;
curl_close($ch);
結果として、私はリストされたオファーがあるページの代わりにログインページを取得します。
私は何が間違っているのか教えてください。
awesome! :)それは今働いている!ご協力ありがとうございました。 – user3626048