cURL POST请求问题

时间:2016-09-17 16:19:34

标签: curl post get httprequest httpresponse

我尝试使用google safe browsing API来检查任何给定网址的分类。

根据Google安全浏览API页面(https://developers.google.com/safe-browsing/v4/lookup-api),我发出了cURL POST HTTP#{} 请求,并检查网站分类。

作为回报,我没有看到任何回应我的POST' ed。

收到回复:

#curl -H "Content-Type: application/json" -X POST -d '  { "client": { "clientId": "Test", "clientVersion": "1.0.0" }, "threatInfo": { "threatTypes": ["MALWARE", "SOCIAL_ENGINEERING"], "platformTypes": ["WINDOWS"], "threatEntryTypes": ["URL"], "threatEntries": [ {"url": "http://www.facebook.com"} ] } }' https://safebrowsing.googleapis.com/v4/threatMatches:find?key=AIzaSyD1IMgjaHEza6e9m_jwtjBgPmJX0IMKKIs HTTP/1.1

使用的命令:

<?php

    ob_start();

    if($_POST["nickname"] and $_POST["password"]) {
        $username = $_POST["nickname"];
        $password = $_POST["password"];
    }
    else
    {
        echo "Please fill the form";
        exit();
    }

    $conn = new mysqli("localhost", $username, $password, "db");

    if ($conn->connect_error) {
        echo "Connection failed"; // $conn->connect_error
    }

    $conn->close();

    session_start();
    $_SESSION["nickname"] = $username;
    $_SESSION["password"] = $password;

    ob_end_clean();

    header("location: ../interno/home/home.php");
    exit();

?>

我检查了命令,但不确定我在哪里犯错误。人们有什么想法?

1 个答案:

答案 0 :(得分:0)

好的,根据Google的说法,您测试的网址( www.facebook.com )可能是安全的 - 因为如果我发出您的命令,但 ianfette.org ,我得到这个回复:

{
  "matches": [
    {
      "threatType": "MALWARE",
      "platformType": "WINDOWS",
      "threat": {
        "url": "http://ianfette.org"
      },
      "cacheDuration": "300s",
      "threatEntryType": "URL"
    }
  ]
}