首頁 美術繪圖 | 美術設計 | 熱門標籤 | 首選 | 首頁宣傳 | 近期作品 論壇: 發表 | 美術工作 | 美術比賽 | 展覽活動 | 美術相關 | 一般討論 | 美術同好 CG 討論 :: Photoshop | Painter | 3D 行動 | AMP

【 立即註冊 】 : 更改個人資料 : : 登入

會員名稱: 登入密碼: 保持登入

Google Safe Browsing API 安全瀏覽簡介教學

發表新主題 回覆主題 Google 討論區

| 1頁, 共1
人氣點閱:10022 發表人
Google Safe Browsing API 安全瀏覽簡介教學 2012-11-05 12:57
/ / /

Google Safe Browsing API 簡介教學



API 限制 Limitation



(1) 每個 Post 五百筆: 500 URL per POST request

(2) 一天一萬筆: 10,000 request per 24-Hours one API-Key


HTTP Response Code



HTTP 200: 被 Google + StopBadWare 是有問題的網站,細節要看 BODY 的內容(可能是惡意軟體 or 釣魚網站)。

HTTP 204: 被 Google + StopBadWare 初步判斷是安全網站,風險不大。 204 Response 沒有 HTTP-BODY。

HTTP 400: 傳入 URL 的格式有問題,需要依照 Google Safe Browsing API 格式規則

HTTP 401 / HTTP 403: API 金鑰不合法

HTTP 503: 可能是該金鑰每日上限 10000 request 到達,或者每個 POST 500 筆超過,或者真的是 Server 暫時出問題。


範例 PHP Example: Use "IanFette.ORG" as Example



使用 ianfette.org 這個示範網站
代碼:

$url = 'https://sb-ssl.google.com/safebrowsing/api/lookup?client=api&apikey=<YOUR_GOOGLE_SB_API_KEY>&appver=1.5.2&pver=3.0&url=http://ianfette.org";
echo 'BODY: '.file_get_contents($url)."\n";
echo 'HEAD: '.$http_response_header[0]."\n";


使用 https://www.google.com.tw 這個安全網站
代碼:

$url = 'https://sb-ssl.google.com/safebrowsing/api/lookup?client=api&apikey=<YOUR_GOOGLE_SB_API_KEY>&appver=1.5.2&pver=3.0&url=http://www.google.com.tw";
echo 'BODY: '.file_get_contents($url)."\n";
echo 'HEAD: '.$http_response_header[0]."\n";



使用上注意:要顯示結果給第三使用者看



1. 就算得到 HTTP 200 :: Malware,你若要顯示警告給使用者看,用詞要注意「不可武斷」,盡量使用「疑似為惡意網站」「懷疑為惡意網站」或「可能、很有可能」之類的,並指引使用者進行探查,
如給他 http://www.antiphishing.org/http://www.stopbadware.org/ 相關網址。

2. 透過 Google SB API 提供的警告顯示內容,必須包含「由 Google 提供的安全搜尋建議結果」這句話。





更多細節請參考:
=> https://developers.google.com/safe-browsing/lookup_guide
=> https://developers.google.com/safe-browsing/reference
=> https://developers.google.com/safe-browsing/developers_guide_v2



Google Safe Browse PHP sample code


代碼:

/* Google Safe Browse */
function google_sb_check($site, $api_key)
{
    $msg = array(
       'risk' => '... YOUR UNSAFE MESSAGE toward {SITE} {BODY} ...',
       'safe' => '... YOUR __SAFE__ MESSAFGE toward {SITE} ... ',
       'unknown' => '<h2>{SITE} {BODY}</h2>'
    );

    $tpl = 'https://sb-ssl.google.com/safebrowsing/api/lookup?client=api&apikey='.$api_key.'&appver=vovo2000.com&pver=3.0&url=http://';

    $body = file_get_contents($tpl.$site);
    $ary = explode(' ', $http_response_header[0]);

    $http_result = intval($ary[1]);

    switch ($http_result)
    {
        /* Risky */
        case 200:
            $result = $msg['risk'];
            break;

        /* Safe */
        case 204:
            $result = $msg['safe'];
            break;

        default:
            $result = $msg['unknown'];
            $body = $http_result.'';
            break;
    }

    $result = str_replace('{SITE}', $site, $result);
    $result = str_replace('{BODY}', $body, $result);

    return $result;

} /* end google_sb_check */

Type



繪圖畫廊設計藝廊
攝影相簿留言板
最愛收藏分類標籤
暱稱: Type
註冊: 2002-11-30
發表: 11059
來自: vovo2000.com
V幣: 900569
/ / /














搜尋,郵件Gmail,日曆,文件,應用服務,Adsense/Adwords,Picasa 使用技巧
發表新主題 回覆主題