Merge lp:~diesch/python-snippets/pygtk-snippets into lp:~jonobacon/python-snippets/trunk

Proposed by Florian Diesch
Status: Needs review
Proposed branch: lp:~diesch/python-snippets/pygtk-snippets
Merge into: lp:~jonobacon/python-snippets/trunk
Diff against target: 83 lines (+79/-0)
1 file modified
twitter/identica.py (+79/-0)
To merge this branch: bzr merge lp:~diesch/python-snippets/pygtk-snippets
Reviewer Review Type Date Requested Status
Akkana Peck (community) Approve
Jono Bacon Pending
Review via email: mp+24066@code.launchpad.net

Description of the change

added twitter/identica.py: get timeline and update status from identi.ca

To post a comment you must log in.
Revision history for this message
Akkana Peck (akkzilla) wrote :

Hi -- I'm a new maintainer python-snippets. Your snippet works great for identi.ca, but if I uncomment the twitter lines there's a syntax error for SECURE= . What should SECURE be set to? Or should I just remove the commented-out twitter lines and commit it just for the identi.ca part?

review: Needs Information
Revision history for this message
Florian Diesch (diesch) wrote :

It's been a while since that. But I guess it should be

 # SECURE=False

Quite likely that doesn't work anymore as I don't think Twitter supports that kind of authentication anymore so you'll may want to remove all the Twitter related stuff.

Revision history for this message
Akkana Peck (akkzilla) wrote :

Okay, I'll remove the twitter stuff. They broke a lot of python_twitter code too when they disabled basic authentication. The rest looks fine. I'm having some trouble figuring out launchpad and merges -- all the merge requests for python-snippets are against Jono's branch, and there doesn't seem to be any way to close them even when I approve the merges, but I'll check this in as soon as I get that figured out. Thanks for the contribution!

Revision history for this message
Akkana Peck (akkzilla) wrote :

... but at least I can mark it Approved for now.

review: Approve

Unmerged revisions

100. By Florian Diesch

added twitter/identica.py

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'twitter/identica.py'
2--- twitter/identica.py 1970-01-01 00:00:00 +0000
3+++ twitter/identica.py 2010-04-24 22:34:15 +0000
4@@ -0,0 +1,79 @@
5+#!/usr/bin/env python
6+#-*- coding: utf-8-*-
7+
8+# [SNIPPET_NAME: Access identi.ca]
9+# [SNIPPET_CATEGORIES: twitter]
10+# [SNIPPET_DESCRIPTION: get timeline and update status from identi.ca]
11+# [SNIPPET_AUTHOR: Florian Diesch <diesch@spamfence.net>]
12+# [SNIPPET_DOCS: http://joshthecoder.github.com/tweepy/docs/index.html]
13+# [SNIPPET_LICENSE: MIT]
14+
15+# Copyright 2010 Florian Diesch <diesch@spamfence.net>
16+# All rights reserved.
17+#
18+# Permission is hereby granted, free of charge, to any person obtaining a copy
19+# of this software and associated documentation files (the "Software"), to deal
20+# in the Software without restriction, including without limitation the rights
21+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22+# copies of the Software, and to permit persons to whom the Software is
23+# furnished to do so, subject to the following conditions:
24+#
25+# The above copyright notice and this permission notice shall be included in
26+# all copies or substantial portions of the Software.
27+#
28+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
34+# THE SOFTWARE.
35+#
36+
37+import tweepy
38+# See http://joshthecoder.github.com/tweepy/
39+
40+
41+## change this to your account
42+USER='some_user'
43+PASSWORD='12345'
44+
45+## for identi.ca
46+HOST='identi.ca'
47+API_ROOT='/api'
48+SECURE=True
49+
50+## for twitter.com
51+# HOST='api.twitter.com'
52+# API_ROOT='/'
53+# SECURE=
54+
55+
56+auth = tweepy.BasicAuthHandler(USER, PASSWORD)
57+api = tweepy.API(auth,
58+ host=HOST,
59+ api_root=API_ROOT,
60+ secure=SECURE
61+ )
62+
63+
64+## get first 10 items of your home timeline:
65+
66+try:
67+ for status in tweepy.Cursor(api.home_timeline).items(10):
68+ print '-'*20
69+ print status.user.screen_name
70+ print status.author.name
71+ print status.text
72+except tweepy.error.TweepError, e:
73+ print 'Error getting timeline:', e
74+
75+## update your status:
76+try:
77+ api.update_status(status='Trying an example from Acire http://www.launchpad.net/acire')
78+except tweepy.error.TweepError, e:
79+ print "Can't update status:", e
80+else:
81+ print "Updated status."
82+
83+

Subscribers

People subscribed via source and target branches