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: ""
}
我哪里出错了(我已经声明了变量、用户名和密码,但显然已经忽略了)。
解决方案
您无法通过 curl 登录 Airbnb,因为 Airbnb 使用无法解析的谷歌验证码。这就是它返回的原因success: false
。
如果你想对他们的应用做点什么,你应该尝试去这里申请成为合作伙伴,以便使用他们的 API。
推荐阅读
- c++ - C ++ Open CV为相同形状的轮廓绘制一种颜色
- php - php中数据库的下拉菜单
- schema - 如何使用 biml 离线模式
- html - 自定义 Angular Bootstrap 日期选择器弹出按钮
- json - 在 json 中解析响应
- javascript - 在画布周围拖动图像
- mysql - 为什么我的查询在正确时会给出错误错误?
- kubernetes - 如何将多个证书添加到具有 SUB 域 (SNI) 的同一 IP 的入口?
- assembly - 预取队列、缓存、管道、超标量设计
- google-cloud-platform - 修改 Active Storage 云中的图像