当在我的机器上本地使用邮递员时,我能够毫无问题地发送请求并得到响应。由于我发送 api 的令牌无效,我应该收到返回的令牌。
\n\n{\n "status": "Error",\n "message": "Invalid API Token"\n}\nRun Code Online (Sandbox Code Playgroud)\n\n使用邮递员的实用程序生成 php 卷曲代码来发出此请求我得到了这个。
\n\n\n$curl = curl_init();\n\ncurl_setopt_array($curl, array(\n CURLOPT_URL => "https://app.mobilecause.com/api/v2/reports/transactions.json",\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => "",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => "GET",\n CURLOPT_POSTFIELDS => "",\n CURLOPT_COOKIESESSION => true,\n CURLOPT_COOKIEFILE => "cookie.txt",\n CURLOPT_COOKIEJAR => "cookie.txt",\n CURLOPT_FOLLOWLOCATION => true,\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_HTTPHEADER => array(\n \'Authorization: Token token="test_token"\',\n "Content-Type: application/x-www-form-urlencoded",\n "cache-control: no-cache",\n ),\n));\n\ncurl_setopt($curl, CURLOPT_VERBOSE, true);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n echo "cURL Error #:" . $err;\n} else {\n echo $response;\n}\nRun Code Online (Sandbox Code Playgroud)\n\n在我的网络服务器上运行此代码会返回一个页面正文,该页面正文是一个 cloudflare 登录页面,特别是这个。
\n\nPlease enable cookies.\nOne more step\nPlease complete the security check to access app.mobilecause.com\nWhy do I have to complete a CAPTCHA?\nCompleting the CAPTCHA proves you are a human and gives you temporary access to the web property.\n\nWhat can I do to prevent this in the future?\nIf you are on a personal connection, like at home, you can run an anti-virus scan on your device to make sure it is not infected with malware.\n\nIf you are at an office or shared network, you can ask the network administrator to run a scan across the network looking for misconfigured or infected devices.\n\nCloudflare Ray ID: RAY_ID \xe2\x80\xa2 Your IP_REDACTED \xe2\x80\xa2 Performance & security by Cloudflare\nRun Code Online (Sandbox Code Playgroud)\n\n我无法解释为什么会发生这种情况。我有一个正在写入的有效的“cookie.txt”,但它似乎缺少内容。
\n\ncurl 通过此请求写入的 cookie 存储在“cookie.txt”中,如下所示。(已编辑潜在敏感信息。)
\n\n\n#HttpOnly_.app.mobilecause.com TRUE / FALSE shortStringOfNumbers __cfduid longStringOfNumbers\nRun Code Online (Sandbox Code Playgroud)\n\n通过postman执行命令时postman生成的cookie如下所示。(已编辑潜在敏感信息。)
\n\n__cfruid=longStringOfNumbers-shortStringOfNumbers; path=/; domain=.app.mobilecause.com; HttpOnly; Expires=Tue, 19 Jan 2038 03:14:07 GMT;\n__cfduid=longStringOfNumbers; path=/; domain=.app.mobilecause.com; HttpOnly; Expires=Thu, 23 Jan 2020 04:54:50 GMT;\nRun Code Online (Sandbox Code Playgroud)\n\n本质上,php 请求似乎缺少“__cfruid”cookie。这可能是原因吗?
\n\n将此确切代码复制到http://phpfiddle.org/会生成相同的 cloudflare 登录页面。在我的机器上本地运行它会产生预期的结果。
\n您遇到了托管挑战:https://developers.cloudflare.com/fundamentals/get-started/concepts/cloudflare-challenges/
这里的关键问题是您是否拥有该区域。网站所有者可以出于几乎任何原因添加托管挑战作为其 WAF 的一部分: https: //developers.cloudflare.com/waf/。我们可以推测是否是由于您的流量被视为机器人,或者可能是它们根据您的用户代理字符串进行了阻止。如果您不拥有 Cloudflare 中的域,您将无法控制为您提供的托管挑战。
如果您是网站所有者,您可以通过获取 Cloudflare rayID 并在Security>中进行过滤来确定导致此托管挑战的规则Overview。然后,您可以向防火墙规则添加旁路以排除此 PHP curl 流量。
| 归档时间: |
|
| 查看次数: |
6552 次 |
| 最近记录: |