在Twitter上分享(与一点点地短链接
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在Twitter上分享(与一点点地短链接相关的知识,希望对你有一定的参考价值。
//Twitter/Bit.Ly Share Imports import flash.net.navigateToURL; import mx.rpc.events.ResultEvent; import mx.rpc.xml.SimpleXMLDecoder; import mx.utils.ObjectUtil; //Twitter/Bit.Ly Share Vars private var bitLyLoader:URLLoader; /* * Call this function to share on twitter, passing your url trough bit.ly! */ private function twitterShare(articleUrl:String):void { // Insert your bit.ly account name & API Key bellow var bitLyApiUrl:String = "http://api.bit.ly/v3/shorten?login=ACCOUNT NAME&apiKey=API KEY&longUrl="+articleUrl+"&format=xml"; var bitLyApi:URLRequest = new URLRequest(bitLyApiUrl); bitLyLoader = new URLLoader(bitLyApi); bitLyLoader.addEventListener(Event.COMPLETE, bitLyFinished); } /* * Get the short link & post to twitter */ private function bitLyFinished(event:Event):void { // Lets decode the bit.ly answer! var getLink:XMLDocument = new XMLDocument(bitLyLoader.data); var decoder:SimpleXMLDecoder = new SimpleXMLDecoder(true); var bitLyLink:Object = decoder.decodeXML(getLink); // Insert your message bellow! Use %23 for trending topics! (Example: %23DigitalWorks) var URL:String = "http://twitter.com/home?status=Currently reading "+bitLyLink+" %23DigitalWorks"; navigateToURL(new URLRequest(URL), '_blank'); }
以上是关于在Twitter上分享(与一点点地短链接的主要内容,如果未能解决你的问题,请参考以下文章
ActionScript 3 在Twitter上分享(Bit.ly缩短链接)[FLEX]