通过CURL登录到Airbnb

时间:2019-03-29 16:33:28

标签: php curl airbnb

我正在尝试对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: ""
}

我要去哪里了(我已经声明了vars,用户名和密码,但是显然没有列出来。)

1 个答案:

答案 0 :(得分:0)

您无法通过curl登录到Airbnb,因为Airbnb使用的Google验证码无法解析。这就是为什么它返回success: false的原因。

如果您想对他们的应用程序进行某些操作,则应该尝试here并以合伙人身份申请才能使用他们的API。