我正在尝试对Airbnb进行API调用,但您必须登录才能进行这些调用,并且由于没有公共API,我只能尝试并提出解决方案。
我首先尝试通过CURL登录,我正在尝试使用这段代码,但我没有太多的运气。
$url = "https://www.airbnb.co.uk/login";
$postinfo = "email=".$username."&password=".$password;
$cookie_file_path = $path."/cookie.txt";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
//for certain features, set the cookie the site has - this is optional
curl_setopt($ch, CURLOPT_COOKIE, "cookiename=0");
curl_setopt($ch, CURLOPT_USERAGENT,
"Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, $_SERVER['REQUEST_URI']);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postinfo);
curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, $url);
$html_data = curl_exec($ch);
curl_close($ch);
echo $html_data;我得到的回答是:
{
success: false,
redirect: ""
}我哪里错了(我声明了var、用户名和密码,但显然遗漏了它们)。
发布于 2019-03-30 00:49:26
你不能通过curl登录Airbnb,因为Airbnb使用了无法解析的google验证码。这就是它返回success: false的原因。
如果你想用他们的应用程序做一些事情,你应该尝试去here并申请成为合作伙伴,以便使用他们的应用程序编程接口。
https://stackoverflow.com/questions/55421819
复制相似问题