fixed twitter, thanks spametki
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 1.99.4 (2011-12-25 12:24:19) stable
|
Version 1.99.4 (2011-12-25 12:33:19) stable
|
||||||
|
|||||||
@@ -1308,6 +1308,7 @@ def update_languages():
|
|||||||
session.flash = T('Language files (static strings) updated')
|
session.flash = T('Language files (static strings) updated')
|
||||||
redirect(URL('design',args=app,anchor='languages'))
|
redirect(URL('design',args=app,anchor='languages'))
|
||||||
|
|
||||||
|
|
||||||
def twitter():
|
def twitter():
|
||||||
session.forget()
|
session.forget()
|
||||||
session._unlock(response)
|
session._unlock(response)
|
||||||
@@ -1315,13 +1316,19 @@ def twitter():
|
|||||||
import gluon.contrib.simplejson as sj
|
import gluon.contrib.simplejson as sj
|
||||||
try:
|
try:
|
||||||
if TWITTER_HASH:
|
if TWITTER_HASH:
|
||||||
page = gluon.tools.fetch('http://twitter.com/%s?format=json'%TWITTER_HASH)
|
page = urllib.urlopen("http://search.twitter.com/search.json?q=%%40%s" % TWITTER_HASH).read()
|
||||||
return sj.loads(page)['#timeline']
|
data = sj.loads(page , encoding="utf-8")['results']
|
||||||
|
d = dict()
|
||||||
|
for e in data:
|
||||||
|
d[e["id"]] = e
|
||||||
|
r = reversed(sorted(d))
|
||||||
|
return dict(tweets = [d[k] for k in r])
|
||||||
else:
|
else:
|
||||||
return 'disabled'
|
return 'disabled'
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
return DIV(T('Unable to download because:'),BR(),str(e))
|
return DIV(T('Unable to download because:'),BR(),str(e))
|
||||||
|
|
||||||
|
|
||||||
def user():
|
def user():
|
||||||
if MULTI_USER_MODE:
|
if MULTI_USER_MODE:
|
||||||
if not db(db.auth_user).count():
|
if not db(db.auth_user).count():
|
||||||
|
|||||||
@@ -150,7 +150,7 @@
|
|||||||
<h3>{{=T("%s Recent Tweets"%TWITTER_HASH)}}</h3>
|
<h3>{{=T("%s Recent Tweets"%TWITTER_HASH)}}</h3>
|
||||||
<div id="tweets">{{=T('loading...')}}</div>
|
<div id="tweets">{{=T('loading...')}}</div>
|
||||||
<script>
|
<script>
|
||||||
jQuery(document).ready(function(){jQuery('#tweets').load('{{=URL('twitter')}}')});
|
jQuery(document).ready(function(){jQuery('#tweets').load('{{=URL('twitter.load')}}');});
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
{{pass}}
|
{{pass}}
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
{{response.headers['web2py-response-flash']=response.flash}}
|
||||||
|
|
||||||
|
{{
|
||||||
|
"""
|
||||||
|
Tweet attributes
|
||||||
|
|
||||||
|
'iso_language_code',
|
||||||
|
'to_user_name',
|
||||||
|
'to_user_id_str',
|
||||||
|
'profile_image_url_https',
|
||||||
|
'from_user_id_str',
|
||||||
|
'text',
|
||||||
|
'from_user_name',
|
||||||
|
'in_reply_to_status_id_str',
|
||||||
|
'profile_image_url',
|
||||||
|
'id',
|
||||||
|
'to_user',
|
||||||
|
'source',
|
||||||
|
'in_reply_to_status_id',
|
||||||
|
'id_str',
|
||||||
|
'from_user',
|
||||||
|
'from_user_id',
|
||||||
|
'to_user_id',
|
||||||
|
'geo',
|
||||||
|
'created_at',
|
||||||
|
'metadata'
|
||||||
|
"""
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{ for t in tweets: }}
|
||||||
|
{{ =DIV(H5(t["from_user_name"])) }}
|
||||||
|
{{ =DIV(t["text"]) }}
|
||||||
|
{{ =BR() }}
|
||||||
|
{{ pass }}
|
||||||
Reference in New Issue
Block a user