- 浏览: 139890 次
- 性别:
- 来自: 重庆
文章分类
- 全部博客 (22)
- 网站整合谷歌搜索引擎 (1)
- Android 技术 (12)
- android使用Canvas (1)
- 柱状图和饼图源码 (1)
- 东京政府决定从私人手中购买钓鱼岛 (1)
- Android 技术 百度地图 技术大揭秘 (1)
- Android 微信 分享 (1)
- Android 技术 框架架构 (1)
- Android apktool 多渠道 打包 (1)
- Android 设备管理器 不能取消 (1)
- Android 屏蔽Home键 (2)
- Android 技术 卸载弹窗 (1)
- Android 技术 旋转箭头 (1)
- Android WebView解决网页嵌套iframe获取不了标题的问题 (1)
最新评论
-
CAREIT:
干货
Android开发网上的一些重要知识点[经验分享] -
vase:
我就说嘛,照着改了个出来,看着总感觉有点不对劲,果然有坑。
Android 微信分享操作后 在当前界面提示方案 解决 -
flyingsir_zw:
确实解决问题了,这个结果响应,文档写的确实有些模糊,这里的方法 ...
Android 微信分享操作后 在当前界面提示方案 解决 -
hyp712:
macleo 写道话说微信的sdk,坑爹坑的厉害啊
真是有点坑 ...
Android 微信分享操作后 在当前界面提示方案 解决 -
带个回家:
macleo 写道话说微信的sdk,坑爹坑的厉害啊现在好多了。 ...
Android 微信分享操作后 在当前界面提示方案 解决
Posted by : http://developer.aiwgame.comIntroductionThe first thing coming to mind when we hear Google is search engine. Googlehas been able to turn the search business up-side-down within the last fiveyears. The founders of Google started with an idea in 95 which really becamewidely used and known in 98/99. Today Google is the number one search engine.You can find out more about Google?s history here. Like otherorganizations Google is trying to establish itself as a platform rather then asolution. This means it provides the necessary tools and infrastructure so otherpeople can build their own solutions on top of it. Google provides a web serviceinterface which allows you to integrate Google searches right into yourapplication. You can find out more about the Google web service API at http://www.google.ca/apis .
How to get started with the Google APIYou can download from the URL above the developer?s kit which comes with anumber of sample applications for different languages like .NET or Java. Youalso need a valid license key, which you need to pass along with every webservice call. To obtain a Google license key visit the URL http://www.google.ca/apis and select?Create Account? on the left side navigation bar. You need to create an accountby entering your email address and a password. This sends an email to the emailaddress you entered to verify its existence. The email you receive has a link tocomplete the account creation by activating it. When done click on the continuelink which brings you back to the account creation page. At the bottom of thepage you see a link ?sign in here?. Follow the link and sign into your accountwith your email address and password. This shows then a page confirming that alicense key has been generated and sent to your email address. Should you looseyour license key, sign in again and Google will resend the license key to youremail address. The license key is for free but limits you to 1,000 calls perday. This will be more then enough to get started. If you need to make more then1,000 calls per day contact Google.
How to reference the Google web service API in your projectCreate your project in Visual Studio .NET and in the "solution explorer" paneright click on the project. In the popup menu select ?Add Web Reference? andenter as URL the following WSDL URL – http://api.google.com/GoogleSearch.wsdl. This will check the existence of the WSDL, download it and show you in thedialog the web methods available by this web service. Enter under ?web referencename? the name of the web service reference, for example GoogleSearch. When doneclick ?Add Reference? and you are ready to use the Google web service API. Itwill be shown in the ?solution explorer? under ?Web References?. You can rightclick on the web service reference and update it through the ?Update WebReference? menu item or view it in the object explorer through the ?View inObject Browser? popup menu. This shows you that there are four different typesavailable. The type GoogleSearchService exposes the actual web service calls youcan make. It has three different web methods (plus the usual Begin/End methodsif you want to call a web method asynchronously).
GoogleSearchService.doSpellingSuggestion()When you open up Google in your browser and search for a word or phrase yousee sometimes the phrase ?Did you mean: [suggested search term]? at the top ofthe search results page. Google performs a spell check of the search term youentered and then shows you alternative spellings of your search term. This helpsthe user to search for properly spelled words and phrases and the user cansimply click on it to search for the corrected search term. The Google webservice also provides a web method to check for alternate spellings of a searchterm. Here is a code snippet: public static string SpellingSuggestion(string Phrase) // get the new spelling suggestion // null means we have no spelling suggestion // release the web service object First we create an instance of the web GoogleSearchService class and then wecall the web method doSpellingSuggestion(). The first argument is the Googlelicense key you pass along and the second one is the search term. The web methodreturns the alternate spelling of the search term or null if there is noalternate spelling. The code snippet above returns the alternate spelling or theoriginal one. At the end it calls Dispose() to free up the underlying unmanagedresource.
GoogleSearchService.doGetCachedPage()Google is constantly crawling the Internet to keep its search index anddirectory up to date. Google?s crawler also caches the content locally on itsservers and allows you to obtain the cached page, which is the content as ofwhen the crawler visited that resource the last time. URL?s can point to manydifferent resources, most typically to HTML pages. But these can also be Worddocuments, PDF files, PowerPoint slides, etc. The cached page is always in HTMLformat. So for any other resources then HTML it also converts the format toHTML. Here is a code snippet: public static void GetCachedPageAndSaveToFile(string PageUrl, string // get the cached page content // file writer to write a stream to the file & a binary writer to write // write the page content to the file and close the streams; // release the web service object First we again create an instance of the GoogleSearchService class and thenwe call the web method doGetCachedPage(). We pass along the Google license keyplus the URL of the page we are looking for. This returns a byte array, usingbase64 encoding, which contains the HTML content of the cached page. Next wecreate a FileStream which we use to write the obtained page to a local file.With FileMode.Create we tell it to create the file, which overwrites anyexisting file. Then we create a BinaryWriter which uses as output theFileStream. Then we write the returned byte array to the BinaryWriter which inturn writes it to the FileStream, which in turn writes it to the local file.Then we close the FileStream and BinaryWriter. At the end we call againDispose() to free up underlying unmanaged resources.
GoogleSearchService.doGoogleSearch()The web method doGoogleSearch() allows you to perform searches. You passalong the search term and then certain filter criteria?s to filter the contentfor exa mple to
This web method allows you to perform simple or complex search queriesagainst Google. It also allows you to filter the search result as well as pagethrough the search result. Here is a code snippet: public static XmlNode Search(string QueryTerm, int Start, int // perform search // we return the result back as a XML document // add the search result // add the result elements and directory categories root node // now add all result elements // now add all directory categories // release the web service object First we create an instance of the GoogleSearchService class and then we callthe web method doGoogleSearch(). We pass along all the arguments as describedabove. This performs the search and returns its result as an instance of theGoogleSearchResult class. The code snippet then takes all values of theGoogleSearchResult object and puts them into a XML document. Please refer to theattached sample application for the complete code. First it creates a XMLdocument with the method CreateXmlDocument(). It then calls the methodStringValueOfObject() which creates a XML element for the object in the XMLdocument using the name of the object as the name of the XML element. The methoduses then reflection to walk the returned GoogleSearchResult object and for eachfield it finds in the object it adds an attribute to the created XML element. Itof course adds to each created attribute the value of the associated objectfield. The returned GoogleSearchResult object has two fields which hold an arrayof ResultElement and DirectoryCategory objects. The method StringValueOfObject()is not able to walk each object in those arrays. Therefore we create two rootXML elements in the XML document using the method AddChildElement(). We thenloop through both arrays and call for each object StringValueOfObject() so wecan convert each object to a XML element adding all its fields as attributes.Finally we call again Dispose() to free up the underlying unmanaged resourcesand then return the XML document which contains all search information of theGoogleSearchService object. This enables you to run XPath queries against thesearch result XML document to find the required search result information.
The attached sample applicationThe attached sample application provides a wrapper class for all Google webmethods. It also provides a simple user interface demonstrating the use of eachweb method. You can enter a search term and get alternate spelling suggestions,you can download the cached HTML page of a URL and display it and you canperform a search entering all the search arguments. Please make sure to obtainyour own Google license key and enter it in the app.config file. Download Source
SummaryThe Google web service API is very easy to use. It enables you to search theInternet from within your application. Complex query terms and filteringcapabilities assure relevancy of the search results to your application needs.The Google web service is one of many other emerging ones, like Amazon?s webservice or eBay?s web service. By introducing a web service interface thesecompanies moved to a platform, enabling third parties to build solutions non topof them. For these companies an ever increasing number of requests and businesstransactions are coming through these web service interfaces. If you havecomments on this article or this topic, please contact me @ klaus_salchner@hotmail.co m . I wantto hear if you learned something new. Contact me if you have questions aboutthis topic or article.
About the authorKlaus Salchner has worked for 14 years in the industry, nine years in Europeand another five years in North America. As a Senior Enterprise Architect withsolid experience in enterprise software development, Klaus spends considerabletime on performance, scalability, availability, maintainability,globalization/localization and security. The projects he has been involved inare used by more than a million users in 50 countries on three continents. Klaus calls Vancouver, British Columbia his home at the moment. His next biggoal is doing the New York marathon in 2005. Klaus is interested in guestspeaking opportunities or as an author for .NET magazines or Web sites. He canbe contacted atklaus_salchner@hotmail.com or http://www.enterprise-minds.com/ . Enterprise application architecture and design consulting services areavailable. If you want to hear more about it contact me! Involve me in yourprojects and I will make a difference for you. Contact me if you have an ideafor an article or research project. Also contact me if you want to co-author anarticle or join future research projects! |
相关推荐
Learn how to simplify mail sending with Spring and how to integrate JMS messaging into your application using Spring and ActiveMQ. For more information on the content of this book, check out the ...
By the end of the book, you'll have built a full-featured application, gained a complete understanding of Core Data, and learned how to integrate your application into the iPhone/iPad platform. ...
Until now it's been difficult for ... Part 3 shows you how to integrate Cucumber with your Continuous Integration (CI) system, work with a REST web service, and even use BDD with legacy applications.
This document describes how to quickly integrate TPNS into your iOS application.
- BIEE 10.1.3.2 版本,已安装Advanced Security选项,它包含Web Bridge servlet、JMX BeanServer和Oracle BI Publisher组件,这些组件在Oracle Application Server 10.1.3上运行,而不是默认的OC4J。 - Oracle ...
### 如何在MICROSAR中集成End-to-End保护 #### 概述 本文档旨在指导用户如何在VECTOR AUTOSAR软件MICROSAR中集成End-to-End (E2E)保护功能。E2E保护是一项重要的安全措施,用于确保在汽车电子控制单元(ECU)之间的...
You'll learn the proper procedure for each myofascial technique and understand how to integrate myofascial massage into your bodywork practice. Whether you're looking to broaden your perspective of ...
This book teaches you how to integrate machine learning into your apps. We're going to demystify what machine learning is by investigating how it works and delving into the most important concepts. ...
BDD in Action teaches you the Behavior-Driven Development model and shows you how to integrate it into your existing development process. First you'll learn how to apply BDD to requirements analysis ...
• How to integrate a database into your mobile app. • How to maintain the app Who this book is for: This book is for Android or iOS developers who wish to use a lightweight but flexible database ...
《集成E2E在MICROSAR中的技术参考》 本文档详细介绍了如何在基于AUTOAR 4.2的MICROSAR环境中实现端到端(E2E)保护,主要涉及两种方案:E2E Protection Wrapper(E2E保护包装器)和E2E Transformer(E2E转换器)。...
Then it moves on to using different patterns to abstract the persistence layer into your applications, starting with the flexible Google JSON library to the Hibernate OGM framework and finally ...
This second edition includes many features requested by readers, including how to integrate plugins into your workflow, how to integrate tmux with Vim for seamless navigation - oh, and how to use tmux...
Secure Java: For Web Application Development covers secure programming, risk assessment, and threat modeling—explaining how to integrate these practices into a secure software development life cycle...
In the following chapters, you will deal with task management and learn how to integrate Ant tasks into build scripts. Furthermore, you will learn dependency management, plugin management, and its ...