2

I'm building an Android application which allows people scan QR code and open its content if that is a URL. But before opening, I want to check it's a safe URL. I check Google Safe Browsing API, and it turns out I need to download and save malware and infected URL list, which's impossible for Android client.

There's another way with http://www.google.com/safebrowsing/diagnostic?site= but this have two disadvantages:

1.It doesn't work with full URL or URL paramater:
Work: http://www.google.com/safebrowsing/diagnostic?site=http://example.com
Don't work: http://www.google.com/safebrowsing/diagnostic?site=http://example.com/abc/def?ghi=opq

2.It opens a web page which tell us URL is safe or not, but I'd rather want it return a HTTP status code: like 201 -> safe, 202 -> isn't safe (which is easier to process).

The first disadvantage's not much a problem, but the second's really annoying. Can anyone show me another way around? Really thank.

Anh Tuan
  • 1,728
  • 1
  • 13
  • 25

3 Answers3

1

There is an API that maybe solves all of your problems: http://code.google.com/apis/safebrowsing/

And here is an Java client implementation for it: http://code.google.com/p/jgooglesafebrowsing/

Martín Schonaker
  • 7,273
  • 4
  • 32
  • 55
  • Really thank you. Google Safe Browsing Lookup API is the answer for my problem. But jgooglesafebrowsing library is not, that library is for server, or desktop app, not android app – Anh Tuan Jul 15 '11 at 03:48
0

One thing I would suggest is to have a server side implementation and have an Rest api exposed. Your android app can act as a client for the same

chethu
  • 341
  • 2
  • 4
0

You need to urlencode your URL as you cannot have two ? characters in the URL at the same time.

So your URL should looks like:

https://transparencyreport.google.com/safe-browsing/search?url=http:%2F%2Fexample.com%2Fabc%2Fdef%3Fghi%3Dopq

In Java, you can use URLEncoder.encode().

See: Java URL encoding of query string parameters

kenorb
  • 155,785
  • 88
  • 678
  • 743