Flex中使用Google

以下是我的google搜索

首先的申请一个Account,然后得到他的lisence Key
这样就可以根据wsdl来构造xml提交给api。

程序如下:

|

 1<mx:application verticalgap="10" xmlns:mx="http://www.macromedia.com/2003/mxml">
 2<mx:style>   
 3.blankFont {font-size:12;}   
 4</mx:style>
 5<mx:webservice id="ws" showbusycursor="true" wsdl="http://api.google.com/GoogleSearch.wsdl">
 6<mx:operation name="doGoogleSearch">
 7<mx:request>
 8<!--This is my Lisence Key-->
 9<key>JRuYnw9QFHKM5XYgSMigEbOleKWNr3Qk</key>
10<q>{q.text}</q>
11<start>0</start>
12<maxresults>10</maxresults>
13<filter>true</filter>
14<restrict></restrict>
15<safesearch>true</safesearch>
16<lr></lr>
17<ie></ie>
18<oe></oe>
19</mx:request>
20</mx:operation>
21</mx:webservice>
22<mx:panel stylename="blackFont" title="Google Search" width="500">
23<mx:hbox>
24<mx:textinput id="q" width="210"></mx:textinput>
25<mx:button click="ws.doGoogleSearch.send()" label="Search"></mx:button>
26</mx:hbox>
27<mx:datagrid dataprovider="{ws.doGoogleSearch.result.resultElements}" height="400" id="resultsGrid" width="100%">
28<mx:columns>
29<mx:array>
30<mx:datagridcolumn columnname="title" headertext="Title" width="120"></mx:datagridcolumn>
31</mx:array>
32</mx:columns>
33</mx:datagrid>
34</mx:panel>
35</mx:application>

结果如下图:

本主题包含附件: sf_2004111101824.jpg (34139bytes)


CSDN BLOG: http://blog.csdn.net/stefli

stefli 's MP3: http://stefli.88ip.net/Flex/mp3Player.swf

Published At
Categories with Web编程
Tagged with
comments powered by Disqus