本文整理匯總了Python中pyfb.Pyfb.publish方法的典型用法代碼示例。如果您正苦於以下問題:Python Pyfb.publish方法的具體用法?Python Pyfb.publish怎麽用?Python Pyfb.publish使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyfb.Pyfb
的用法示例。
在下文中一共展示了Pyfb.publish方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: feed
# 需要導入模塊: from pyfb import Pyfb [as 別名]
# 或者: from pyfb.Pyfb import publish [as 別名]
def feed(request):
usergenres = request.user.genretouser.all()
user = request.user
if request.method == 'POST':
form = PostingForm(request.POST)
if form.is_valid():
if request.POST.get('facebookshare'):
try:
fb = FacebookProfiles.objects.get(user=user)
fbk = Pyfb(settings.FACEBOOK_APP_ID, settings.FACEBOOK_SECRET_KEY)
fbk.set_access_token(fb.fbk_token)
fbk.publish(message=form.cleaned_data['content'], id=fb.fbk_id)
except ObjectDoesNotExist:
pass
if request.POST.get('twittershare'):
try:
tw = TwitterProfiles.objects.get(user=user)
twttr = tweepy.OAuthHandler(settings.TWITTER_CONSUMER_KEY, settings.TWITTER_CONSUMER_SECRET)
twttr.set_access_token(tw.oauth_token, tw.oauth_secret)
api = tweepy.API(twttr)
me = api.me()
api.update_status(form.cleaned_data['content'] + ' via @likewyss')
except ObjectDoesNotExist:
pass
return HttpResponseRedirect('/feed/')
else:
form = PostingForm()
var = RequestContext(request, {
'form':form,
'user':request.user,
'genres':usergenres
})
return render_to_response('pages/feed.html', var)
示例2:
# 需要導入模塊: from pyfb import Pyfb [as 別名]
# 或者: from pyfb.Pyfb import publish [as 別名]
query = """
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX niod: <http://purl.org/collections/nl/niod/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX dbp-prop: <http://nl.dbpedia.org/property/>
PREFIX dbp-res: <http://nl.dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?pref WHERE {
?entity niod:nerClass niod:nerclass-per;
owl:sameAs <http://dbpedia.org/resource/Benito_Mussolini>;
niod:pRef ?pref.
}
LIMIT 100
"""
sparql.setQuery(query)
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
for result in results["results"]["bindings"]:
xmldoc = urllib.urlopen(result["pref"]["value"])
msg = ''.join(xmldoc.readlines()[1:])
dom = minidom.parseString(msg)
quotes = dom.getElementsByTagName('quote')
for q in quotes:
facebook.publish(getText(q.childNodes))
#print msg
# facebook.publish(msg)
print "Done."