phplaravelcodeignitersafe-browsing

PHP check website url using safe browsing API


I am trying to check whether the url is safe or not using Google Safe browsing API

I followed following tutorial

https://developers.google.com/safe-browsing/v4/get-started

I have completed following step as per above url guidence

  1. Get an account
  2. Create a project
  3. Set up an API key

finally i end up with https://safebrowsing.googleapis.com/v4/...?key=API_KEY

my question is how i can pass website url to above safe browsing url


Solution

  • The Request body for the post request will look like this:

    {
        "client": {
          "clientId":      "yourcompanyname",
          "clientVersion": "1.5.2"
        },
        "threatInfo": {
          "threatTypes":      ["MALWARE", "SOCIAL_ENGINEERING"],
          "platformTypes":    ["WINDOWS"],
          "threatEntryTypes": ["URL"],
          "threatEntries": [
            {"url": "http://www.urltocheck1.org/"},
            {"url": "http://www.urltocheck2.org/"},
            {"url": "http://www.urltocheck3.com/"}
          ]
        }
    }
    

    As you can see you need to send the url in the threatEntries section. But you are passing the Google url(http://www.google.com), instead add the urls you need to check.

    Its self explanatory, see: url to check1.org ("http://www.urltocheck1.org/")

    source