0
我一直在Google上搜索幾個小時,並且還沒有找到解決這個問題的方法。推特<created_at>價值轉換爲友好的時間格式在Flash
目前,我retrive從Twitter的XML文件中的數據:http://twitter.com/statuses/user_timeline.xml?screen_name=clubbluecanopy
一切正常,我的日期格式顯示了這個:週五08月12日3時25分40秒+0000 2011 但我想讓它顯示這個:17天前
這裏是我的閃存AS3代碼:
var myXMLLoader:URLLoader = new URLLoader();
//myXMLLoader.load(new URLRequest("http://twitter.com/statuses/user_timeline.xml?screen_name=arunshourie"));
myXMLLoader.load(new URLRequest("twitter.php"));
myXMLLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void{
var myXML:XML = new XML(e.target.data);
trace(myXML.status[0].text);
tweet_1.text = String(myXML.status[0].text);
time.text= String(myXML.status[0].created_at);
}
這裏的PHP代碼:
<?php
/*
* @return string
* @param string $url
* @desc Return string content from a remote file
* @author Luiz Miguel Axcar ([email protected])
*/
function get_content($url)
{
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_HEADER, 0);
ob_start();
curl_exec ($ch);
curl_close ($ch);
$string = ob_get_contents();
ob_end_clean();
return $string;
}
#usage:
$content = get_content ("http://twitter.com/statuses/user_timeline.xml?screen_name=clubbluecanopy");
echo $content;
?>
我也使用了crossdomain.xml以及
如果有人能幫助我,我將不勝感激!謝謝! :)
您好,感謝˚F或你的幫助!但在我的文件中有一個錯誤:'錯誤:1180:調用一個可能未定義的方法toRelativeDate.'我把你的代碼放在這個上面:'tweet_1.text = String(myXML.status [0] .text); time.text = String(myXML.status [0] .created_at); '我也把它放在上面,在代碼下面,但是錯誤仍然存在:( – Misty
omg它現在有效!我有多麼愚蠢!非常感謝兄弟!XD – Misty