google api

26
Google API 義義義義義義義義義義 義義義義 [email protected]

Upload: adriel

Post on 06-Jan-2016

368 views

Category:

Documents


0 download

DESCRIPTION

Google API. 義守大學資訊工程學系 歐陽振森 [email protected]. Google 服務. Google Search Gmail Google Maps Google Earth Google News Google Image Search Google Book Search Google Blog Search. Google Notebook Google Desktop Google Toolbar Google 學術搜尋 Google 大學搜尋 Google Alerts YouTube - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Google API

Google API

義守大學資訊工程學系歐陽振森

[email protected]

Page 2: Google API

Google 服務 Google Search Gmail Google Maps Google Earth Google News Google Image Search Google Book Search Google Blog Search

Page 3: Google API

Google Notebook Google Desktop Google Toolbar Google 學術搜尋 Google 大學搜尋 Google Alerts YouTube Google Calendar

Page 4: Google API

orkut Picasa Google Docs Blogger Google Talk Google Groups Google Reader Google SketchUp

Page 5: Google API

Google Analytics Google Translate Google Video Google Trends Google Code Search Google Patent Search Google AdSense Google Adwords Google Page Creator

Page 6: Google API

API

Application Programming Interface: API 是一組作為應用程式呼叫某個功能與服務的函數。程式設計師可依據 API 函數撰寫程式,讓作業系統或某個程式啟動某個程式以執行特定的功能。 應用程式 介面

根據 API 定義的方式呼叫相對應的功能

Page 7: Google API

Google API (1)

Android Google AJAX Search API Google APP Engine Google Calendar API Google Chart API Gadgets Google Gears Google Maps API

Page 8: Google API

Google API (2)

OpenSocial YouTube API Google Data API Blogger API Google AJAX Feed API

Page 9: Google API

簡介 Google 搜尋服務之包裝 由 JavaScript 所構成的函式庫 可放在自己的網站或部落格中 服務範圍:網頁搜尋、本地搜尋、影片搜尋、

部落格搜尋、新聞搜尋、書籍搜尋、圖片搜尋 組成元件:搜尋控制器、搜尋器、搜尋結果物

件、額外的設定物件 專屬論壇: Google AJAX Search API 論壇

Page 10: Google API

Google AJAX Search API Key

須先申請 Google AJAX Search API key 申請網址: http://code.google.com/intl/zh-

TW/apis/ajaxsearch/signup.html

Page 11: Google API

程式範例一 範例一: HelloWorld.html

Page 12: Google API

搜尋控制容器 用來裝載搜尋功能的容器 所有搜尋功能的物件必須放入這個容器才能運

作 包含兩種物件:

google.search.SearchControl google.search.SearchForm

Page 13: Google API

Google.search.SearchControl 建立物件

var searchControl = new google.search.SearchControl; 加入搜尋器

addSearcher(searcher,opt_options) 搜尋器 :

google.search.WebSearch ( 網頁搜尋 ) google.search.LocalSearch ( 當地搜尋 ) google.search.VideoSearch ( 影片搜尋 ) google.search.BlogSearch ( 部落格搜尋 ) google.search.NewsSearch ( 新聞搜尋 ) google.search.BookSearch ( 書籍搜尋 ) google.search.ImageSearch ( 圖片搜尋 )

Page 14: Google API

Google.search.SearchControl

練習一 請將各種搜尋器加入範例一中。

搜尋界面繪製 draw(element, GdrawOptions)

執行關鍵字搜尋 execute(str)

練習二 請用自己的名字當關鍵字來搜尋。

Page 15: Google API

Google.search.SearchControl

搜尋不到結果時,網頁所顯示之文字 setNoResultsString(str)

練習三 請設定當搜尋不到結果,網頁顯示” Google 太遜了

啦”。

Page 16: Google API

Google.search.SearchForm

建立物件 var searchForm =

new google.search.SearchForm(enableClear,element); 設定點選搜尋按鈕後所呼叫的物件與函式

setOnSubmitCallback(object,method) 範例二: 2-12.html

Page 17: Google API

Google.search.SearchForm

設定點選搜尋輸入欄位的清除按鈕後所呼叫的物件與函式 setOnClearCallback(object,method) 範例三: 2-13.html

設定搜尋關鍵字 execute(query)

練習四 請設定點選搜尋輸入欄位的清除按鈕後彈出一個視

窗顯示搜尋關鍵字”自己的名字”。

Page 18: Google API

網頁搜尋器 建立物件

var searcher=new google.search.WebSearch(); 限制所要搜尋的對象

setSiteRestriction(site,refinement,moreResults) 範例四: 2-15.html

對搜尋結果進行過濾 setRestriction(type,opt_value) type: google.search.Search.RESTRICT_SAFESEARCH

opt_value: google.search.Search.SAFESEARCH_STRICT

google.search.Search.SAFESEARCH_MODERATE

google.search.Search.SAFESEARCH_OFF

Page 19: Google API

本地搜尋器 建立物件

var searcher=new google.search.LocalSearch(); 針對特定地理區域進行搜尋

setCenterPoint(location) 範例五: 2-17.html

是否要針對地址進行搜尋 setAddressLookupMode(mode) mode:

google.search.LocalSearch.ADDRESS_LOOKUP_DISABLED

google.search.LocalSearch.ADDRESS_LOOKUP_ENABLED

Page 20: Google API

影片搜尋器 建立物件

var searcher=new google.search.VideoSearch(); 搜尋結果的排序順序

setResultOrder(orderBy) orderBy: google.search.Search.ORDER_BY_RELEVANCE

google.search.Search.ORDER_BY_DATE

Page 21: Google API

部落格搜尋器 建立物件

var searcher=new google.search.BlogSearch(); 限制所要搜尋的對象

setSiteRestriction(site) 搜尋結果的排序順序

setResultOrder(orderBy) orderBy: google.search.Search.ORDER_BY_RELEVANCE

google.search.Search.ORDER_BY_DATE

Page 22: Google API

新聞搜尋器 建立物件

var searcher=new google.search.NewsSearch(); 限制所要搜尋的對象

setSiteRestriction(site) 搜尋結果的排序順序

setResultOrder(orderBy) orderBy: google.search.Search.ORDER_BY_RELEVANCE

google.search.Search.ORDER_BY_DATE

Page 23: Google API

書籍搜尋器 建立物件

var searcher=new google.search.BookSearch(); 對搜尋結果進行過濾

setRestriction(type,opt_value) type: google.search.Search.RESTRICT_TYPE

opt_value: google.search.BookSearch.TYPE_FULL_VIEW_BOOKS

google.search.BookSearch.TYPE_ALL_BOOKS

Page 24: Google API

圖片搜尋器 建立物件

var searcher=new google.search.ImageSearch(); 對搜尋結果進行過濾

setRestriction(type,opt_value) type: google.search.Search.RESTRICT_SAFESEARCH

google.search.ImageSearch.RESTRICT_IMAGESIZE

google.search.ImageSearch.RESTRICT_COLORIZATION

google.search.ImageSearch.RESTRICT_FILETYPE

google.search.ImageSearch.RESTRICT_IMAGETYPE

Page 25: Google API

圖片搜尋器 opt_value google.search.Search.RESTRICT_SAFESEARCH

google.search.Search.SAFESEARCH_STRICT google.search.Search.SAFESEARCH_MODERATE google.search.Search.SAFESEARCH_OFF

google.search.ImageSearch.RESTRICT_IMAGESIZE google.search.ImageSearch.IMAGESIZE_SMALL google.search.ImageSearch.IMAGESIZE_MDEIUM google.search.ImageSearch.IMAGESIZE_LARGE google.search.ImageSearch.IMAGESIZE_EXTRA_LARGE

Page 26: Google API

圖片搜尋器 google.search.ImageSearch.RESTRICT_COLORIZATION

google.search.ImageSearch.COLORIZATION_BLACK_AND_WHITE google.search.ImageSearch.COLORIZATION_GRAYSCALE google.search.ImageSearch.COLORIZATION_COLOR –

google.search.ImageSearch.RESTRICT_FILETYPE google.search.ImageSearch.FILETYPE_JPG google.search.ImageSearch.FILETYPE_PNG google.search.ImageSearch.FILETYPE_GIF google.search.ImageSearch.FILETYPE_BMP

google.search.ImageSearch.IMAGETYPE_FACES google.search.ImageSearch.IMAGETYPE_FACES