Kduks
홈
태그
미디어로그
위치로그
방명록
My Study/Flex
플렉스 오픈 API를 이용한 작업
Kduks
2009. 2. 16. 15:19
반응형
플렉스를 이용해 대형매체들의 오픈소스를 적용해봤습니다.
네이버 오픈API인 실시간 검색순위를 적용해봤습니다.
개인키라 하루 25000번이 트랙피제한이라 하는군요,,
하루동안 트래픽제한 걸릴수도 있습니다 ㅋㅋ
일단 소스는
너무 엉터리로 짜서 민망 ㅎㅎ
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" verticalScrollPolicy="off" horizontalScrollPolicy="off" backgroundColor="white" layout="absolute" creationComplete="init(); httpServiceCall();"> <mx:Style> Application { font-size : 12; } Label { font-weight : bold; } ApplicationControlBar { background-color : #cacccc; background-alpha : 0.2; } </mx:Style> <mx:Script> <![CDATA[ import flash.net.navigateToURL; import mx.effects.Move; import mx.collections.ArrayCollection; import mx.rpc.http.HTTPService; import mx.rpc.events.ResultEvent; import mx.rpc.events.FaultEvent; import mx.controls.Alert; import mx.effects.easing.*; private var xmlHttp:HTTPService = new HTTPService(); [Bindable] public var naverXml:Object; [Bindable] public var kdukArr:ArrayCollection = new ArrayCollection(); [Bindable] public var kdukTime:Timer = new Timer(10000, 0); private function init():void { kdukTime.addEventListener(TimerEvent.TIMER, onkdukTime); } public function httpServiceCall():void { kdukTime.stop(); kdukTime.removeEventListener(TimerEvent.TIMER, onkdukTime); function resultHandler(event:ResultEvent):void { xmlHttp.removeEventListener("result", resultHandler); naverXml = event.result.item; kdukArr.removeAll(); kdukArr.addItem({title:naverXml.R1.K, ud:naverXml.R1.S, chg:naverXml.R1.V}); kdukArr.addItem({title:naverXml.R2.K, ud:naverXml.R2.S, chg:naverXml.R2.V}); kdukArr.addItem({title:naverXml.R3.K, ud:naverXml.R3.S, chg:naverXml.R3.V}); kdukArr.addItem({title:naverXml.R4.K, ud:naverXml.R4.S, chg:naverXml.R4.V}); kdukArr.addItem({title:naverXml.R5.K, ud:naverXml.R5.S, chg:naverXml.R5.V}); kdukArr.addItem({title:naverXml.R6.K, ud:naverXml.R6.S, chg:naverXml.R6.V}); kdukArr.addItem({title:naverXml.R7.K, ud:naverXml.R7.S, chg:naverXml.R7.V}); kdukArr.addItem({title:naverXml.R8.K, ud:naverXml.R8.S, chg:naverXml.R8.V}); kdukArr.addItem({title:naverXml.R9.K, ud:naverXml.R9.S, chg:naverXml.R9.V}); kdukArr.addItem({title:naverXml.R10.K, ud:naverXml.R10.S, chg:naverXml.R10.V}); var arr:Array = [sb1, sb2, sb3, sb4, sb5, sb6, sb7, sb8, sb9, sb10]; var arrl:Array = [sl1, sl2, sl3, sl4, sl5, sl6, sl7, sl8, sl9, sl10]; try { for (var i:int = 0; i < 10; i++) { arr[i].label = kdukArr.getItemAt(i).title; if (kdukArr.getItemAt(i).ud == "+") { arrl[i].text = "▲ "; } else if (kdukArr.getItemAt(i).ud == "-") { arrl[i].text = "▼ "; } else arrl[i].text = kdukArr.getItemAt(i).ud; if (kdukArr.getItemAt(i).chg == "0") { arrl[i].text += "-"; } else arrl[i].text += kdukArr.getItemAt(i).chg; } } catch (err:*) { Alert.show("연결 데이터 에러!"); } xmlHttp.disconnect(); } function faultHandler(event:FaultEvent):void { xmlHttp.removeEventListener("fault", faultHandler); Alert.show("fault : " + event.fault); xmlHttp.disconnect(); } xmlHttp.resultFormat = "e4x"; xmlHttp.url = "http://openapi.naver.com/search"; xmlHttp.request.key = "발급받은Key"; xmlHttp.request.query = "nexearch"; xmlHttp.request.start = "1"; xmlHttp.request.target = "rank"; xmlHttp.addEventListener("result", resultHandler); xmlHttp.addEventListener("fault", faultHandler); xmlHttp.send(); kdukTime.addEventListener(TimerEvent.TIMER, onkdukTime); kdukTime.start(); } private function onkdukTime(evt:TimerEvent):void { var arr:Array = [sb1, sb2, sb3, sb4, sb5, sb6, sb7, sb8, sb9, sb10]; var arrl:Array = [sl1, sl2, sl3, sl4, sl5, sl6, sl7, sl8, sl9, sl10]; var meft1:Move = new Move(); var meft2:Move = new Move(); meft1.duration = 1300; meft2.duration = 1300; meft1.easingFunction = Elastic.easeInOut; meft2.easingFunction = Elastic.easeInOut; meft1.targets = arr; meft2.targets = arrl; meft1.yTo = -50; meft2.yTo = -50; meft1.play(); meft2.play(); meft1.startDelay = 900; meft2.startDelay = 900; httpServiceCall(); meft1.yFrom = -50; meft2.yFrom = -50; meft1.yTo = 5; meft2.yTo = 6; meft1.play(); meft2.play(); eft.addChild(meft1); eft.addChild(meft2); eft.play(); } private function clickData(inData:String):void { var str:String = "http://search.naver.com/search.naver?where=nexearch&query=" + inData + "&x=0&y=0&sm=top_hty&fbm=1"; var url:URLRequest = new URLRequest(str); navigateToURL(url, "_blank"); } ]]> </mx:Script> <mx:Parallel id="eft" /> <mx:ApplicationControlBar x="10" y="38" width="310"> <mx:Label text="1. "/> <mx:Button id="sb1" click="clickData(this.sb1.label);" width="207"/> <mx:Label id="sl1" /> </mx:ApplicationControlBar> <mx:ApplicationControlBar x="10" y="79" width="310"> <mx:Label text="2. "/> <mx:Button id="sb2" click="clickData(this.sb2.label);" width="207"/> <mx:Label id="sl2" /> </mx:ApplicationControlBar> <mx:ApplicationControlBar x="10" y="120" width="310"> <mx:Label text="3. "/> <mx:Button id="sb3" click="clickData(this.sb3.label);" width="207"/> <mx:Label id="sl3" /> </mx:ApplicationControlBar> <mx:ApplicationControlBar x="10" y="161" width="310"> <mx:Label text="4. "/> <mx:Button id="sb4" click="clickData(this.sb4.label);" width="207"/> <mx:Label id="sl4" /> </mx:ApplicationControlBar> <mx:ApplicationControlBar x="10" y="202" width="310"> <mx:Label text="5. "/> <mx:Button id="sb5" click="clickData(this.sb5.label);" width="207"/> <mx:Label id="sl5" /> </mx:ApplicationControlBar> <mx:ApplicationControlBar x="10" y="243" width="310"> <mx:Label text="6. "/> <mx:Button id="sb6" click="clickData(this.sb6.label);" width="207"/> <mx:Label id="sl6" /> </mx:ApplicationControlBar> <mx:ApplicationControlBar x="10" y="284" width="310"> <mx:Label text="7. "/> <mx:Button id="sb7" click="clickData(this.sb7.label);" width="207"/> <mx:Label id="sl7" /> </mx:ApplicationControlBar> <mx:ApplicationControlBar x="10" y="325" width="310"> <mx:Label text="8. "/> <mx:Button id="sb8" click="clickData(this.sb8.label);" width="207"/> <mx:Label id="sl8" /> </mx:ApplicationControlBar> <mx:ApplicationControlBar x="10" y="366" width="310"> <mx:Label text="9. "/> <mx:Button id="sb9" click="clickData(this.sb9.label);" width="207"/> <mx:Label id="sl9" /> </mx:ApplicationControlBar> <mx:ApplicationControlBar x="10" y="407" width="310"> <mx:Label text="10."/> <mx:Button id="sb10" click="clickData(this.sb10.label);" width="207"/> <mx:Label id="sl10" /> </mx:ApplicationControlBar> <mx:Image x="90" y="450" height="5" width="133" source="http://openapi.naver.com/logo/logo07_1.gif"/> <mx:Label x="10" y="10" text="Kduks의 네이버 실시간 검색" fontFamily="Georgia" fontSize="13" fontWeight="bold"/> </mx:Application>
네이버 실시간 검색순위 실행화면입니다.
반응형
공유하기
게시글 관리
Kduks
저작자표시
비영리
변경금지
티스토리툴바
Kduks
구독하기