开发者

Simple check URL of Google safe browsing for Android?

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/safebr开发者_运维百科owsing/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.


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/


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜