Twitter<创建于>将值转换为 Flash 中友好的时间格式创建于>
我已经用谷歌搜索了几个小时,但还没有找到这个问题的解决方案。
目前,我从 Twitter xml 文件中检索数据: http://twitter.com/statuses /user_timeline.xml?screen_name=clubbluecanopy
一切正常,我的日期格式显示:Fri Aug 12 03:25:40 +0000 2011年 但我希望它显示这一点: 17 天前
,这是我的 flash 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
,如果有人可以帮助我,我将不胜感激!谢谢! :)
I have been googling for hours and have not yet found a solution to this problem.
currently, I retrive the data from the twitter xml file: http://twitter.com/statuses/user_timeline.xml?screen_name=clubbluecanopy
everything works fine, my date format shows this: Fri Aug 12 03:25:40 +0000 2011
But I want it to show this: 17 days ago
here's my flash as3 code:
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);
}
Here's the php code:
<?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;
?>
I have used crossdomain.xml as well
would appreciate if someone can help me! thanks! :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Fri Aug 12 03:25:40 +0000 2011
表示星期五,2011 年 8 月 12 日,03 小时 25 分 40 秒 GMT是 Flash 的本机日期格式字符串
您可以创建另一个函数,它将为您提供所需的输出:
这 可以按如下方式使用它:
Fri Aug 12 03:25:40 +0000 2011
means Friday, 12th August 2011, 03hrs 25min 40sec GMTThis is Flash's native date formatted string
You can create another function which will give you the required output:
You could use it as follows: