ActionScript 3 在Twitter上分享(Bit.ly缩短链接)[FLEX]

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 在Twitter上分享(Bit.ly缩短链接)[FLEX]相关的知识,希望对你有一定的参考价值。

//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');
}

以上是关于ActionScript 3 在Twitter上分享(Bit.ly缩短链接)[FLEX]的主要内容,如果未能解决你的问题,请参考以下文章

ActionScript 3 获取Twitter ATOM搜索Feed

ActionScript 3 Twitter推文字符串编码实体实用程序

ActionScript 3 使用Twitter API的PlayBook OAuth示例

ActionScript 3 AS3:使用SWX访问Twitter用户的公共时间线

Codeforces Round #535 (Div. 3)小上分记

上分准备 VP Codeforces Round #762 (Div. 3) 4题ABCE