1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174 | from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response
from django.utils import simplejson
import httplib # used for talking to the Fire Eagle server
import oauth # the lib you downloaded
SERVER = 'fireeagle.yahooapis.com'
REQUEST_TOKEN_URL = 'https://fireeagle.yahooapis.com/oauth/request_token'
ACCESS_TOKEN_URL = 'https://fireeagle.yahooapis.com/oauth/access_token'
AUTHORIZATION_URL = 'http://fireeagle.yahoo.net/oauth/authorize'
QUERY_API_URL = 'https://fireeagle.yahooapis.com/api/0.1/user'
QUERY_API_URL_JSON = 'https://fireeagle.yahooapis.com/api/0.1/user.json'
UPDATE_API_URL = 'https://fireeagle.yahooapis.com/api/0.1/update'
# key and secret you got from Fire Eagle when registering an application
CONSUMER_KEY = 'XXXXXXX'
CONSUMER_SECRET = 'XXXXXXXXXXXXXXXXXXXXXXXXXX'
connection = httplib.HTTPSConnection(SERVER)
consumer = oauth.OAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET)
signature_method = oauth.OAuthSignatureMethod_HMAC_SHA1()
# Fire Eagle methods (unrelated to Django):
def fetch_response(oauth_request, connection, debug=False):
url = oauth_request.to_url()
connection.request(oauth_request.http_method,url)
response = connection.getresponse()
s = response.read()
if debug:
print 'requested URL: %s' % url
print 'server response: %s' % s
return s
def get_unauthorised_request_token():
oauth_request = oauth.OAuthRequest.from_consumer_and_token(
consumer, http_url=REQUEST_TOKEN_URL
)
oauth_request.sign_request(signature_method, consumer, None)
resp = fetch_response(oauth_request, connection)
token = oauth.OAuthToken.from_string(resp)
return token
def get_authorisation_url(token):
oauth_request = oauth.OAuthRequest.from_consumer_and_token(
consumer, token=token, http_url=AUTHORIZATION_URL
)
oauth_request.sign_request(signature_method, consumer, token)
return oauth_request.to_url()
def exchange_request_token_for_access_token(request_token):
oauth_request = oauth.OAuthRequest.from_consumer_and_token(
consumer, token=request_token, http_url=ACCESS_TOKEN_URL
)
oauth_request.sign_request(signature_method, consumer, request_token)
resp = fetch_response(oauth_request, connection)
return oauth.OAuthToken.from_string(resp)
def get_location(access_token):
oauth_request = oauth.OAuthRequest.from_consumer_and_token(
consumer, token=access_token, http_url=QUERY_API_URL_JSON
)
oauth_request.sign_request(signature_method, consumer, access_token)
json = fetch_response(oauth_request, connection)
return simplejson.loads(json)
"""
Django views:
1. / Homepage, not logged in
- Intro text plus link to auth with fireeagle
2. /auth/ Auth with fireeagle
- Creates an unauthed token, stashes in COOKIES, redirects user to fireeagle
3. /return/ Return URL
- Checks user's unauthed token COOKIES matches, if not shows error, otherwise
exchanges for access token, stashes that in a COOKIES and redirects the
user to /nearby/ page
4. /nearby/
- Looks up the user's location using their access token, then finds nearby
wikipedia places and plots them on a static Google map
"""
def index(request):
"/"
if request.get_host().startswith('www.'): # Should really be middleware
return HttpResponseRedirect("http://wikinear.com/")
if request.COOKIES.has_key('access_token'):
return HttpResponseRedirect('/nearby/')
else:
return render_to_response('index.html')
def auth(request):
"/auth/"
token = get_unauthorised_request_token()
auth_url = get_authorisation_url(token)
response = HttpResponseRedirect(auth_url)
response.set_cookie('unauthed_token', token.to_string())
return response
def return_(request):
"/return/"
unauthed_token = request.COOKIES.get('unauthed_token', None)
if not unauthed_token:
return HttpResponse("No un-authed token cookie")
token = oauth.OAuthToken.from_string(unauthed_token)
if token.key != request.GET.get('oauth_token', 'no-token'):
return HttpResponse("Something went wrong! Tokens do not match")
access_token = exchange_request_token_for_access_token(token)
response = HttpResponseRedirect('/nearby/')
response.set_cookie('access_token', access_token.to_string())
return response
def nearby(request):
"/nearby/"
access_token = request.COOKIES.get('access_token', None)
if not access_token:
return HttpResponse("You need an access token COOKIES!")
token = oauth.OAuthToken.from_string(access_token)
location = get_location(token)
if location['stat'] != 'ok':
return HttpResponse("Something went wrong: <pre>" + json)
try:
best_location = location['user']['location_hierarchy'][0]
except IndexError:
return HttpResponse(
"Fire Eagle is not currently sharing your location with wikinear.com"
)
geometry = best_location['geometry']
if geometry['type'] == 'Polygon':
bbox = geometry['bbox']
lat, lon = lat_lon_from_bbox(bbox)
is_exact = False
elif geometry['type'] == 'Point':
lon, lat = geometry['coordinates']
is_exact = True
else:
return HttpResponse("Location was not Point or Polygon: <pre>" + json)
nearby_pages = get_nearby_pages(lat, lon)
return render_to_response('nearby.html', {
'lat': lat,
'lon': lon,
'location': location,
'best_location': best_location,
'nearby_pages': nearby_pages,
'is_exact': is_exact,
})
def unauth(request):
response = HttpResponseRedirect('/')
for key in request.COOKIES:
response.delete_cookie(key)
return response
# GeoNames stuff:
import urllib
def lat_lon_from_bbox(bbox):
((lon1, lat1), (lon2, lat2)) = bbox
lat = min(lat1, lat2) + (max(lat1, lat2) - min(lat1, lat2)) / 2
lon = min(lon1, lon2) + (max(lon1, lon2) - min(lon1, lon2)) / 2
return lat, lon
def get_nearby_pages(lat, lon):
return simplejson.load(urllib.urlopen(
'http://ws.geonames.org/findNearbyWikipediaJSON?' +
urllib.urlencode({
'lat': lat,
'lng': lon
})
))['geonames']
|
Comments
I'd like to "undo" my ranking. I did not intend to click "not useful".
#
I nearly marked it "not useful" as well...which would have been a mistake indeed. - Kukri
#
I'd like to "undo" my ranking. I did not intend to click "not useful". car insurance rates
#
Do you need a translation into french or german?? Look at: Übersetzung Deutsch Englisch
#
Or you can translate the website on [HTML_REMOVED]Übersetzungsbüro[HTML_REMOVED]
#
Or you can translate the website on Übersetzungsbüro
#
Using a virtualenv allows you to have all your dependencies in one place, and we like to deploy this under the project folder for convenience .
#
Using a virtualenv allows you to have all your dependencies in one place, and we like to deploy this under the project folder for convenience . car insurance info
#
Do you need a translation into french ? im french blogger on [HTML_REMOVED]6buzz[HTML_REMOVED]
#
See my About page for details.
#
I would like to get across my appreciation for your kindness supporting women who should have assistance with this particular concern. Your very own commitment to getting the message across had been really good and has continuously helped those like me to arrive at their ambitions. Your entire useful instruction denotes so much to me and additionally to my mates. Regards [HTML_REMOVED]Cipto Junaedy[HTML_REMOVED] [HTML_REMOVED]Bank Mandiri Bank Terbaik di Indonesia[HTML_REMOVED]
#
This is very much satisfied by using the different services in this blog. I am using the nice technology in this blog and the great technology and thank a lot for visiting the wonderful website and using the great services in this blog. Bank Mandiri Bank Terbaik di Indonesia Cipto junaedy
#
Many thanks to Fire Eagle for these snippets, I will add them to my Gedore tools arsenal.
#
great post ,just i am finding this info on net for one hour i get more info about that from many blog but nothing like that what you posted . your post is so informative and unique ,i like this and bookmarked your blog and i will try to read your all post . thank you man for posting that great content. please keep it up. http://garagedoorrepair-phoenix.com
#
this is a great post [HTML_REMOVED][HTML_REMOVED]garage door repair phoenix[HTML_REMOVED][HTML_REMOVED]
#
This is what exactly I need, thanks for the Fire Eagle snippets. I will bookmark this post. All Kitchenware
#
Hi. I'd like to "undo" my ranking. I did not intend to click "not useful". Thanks, скачать скайп
#
Hum not so easy... But the task is hard when you want to do a great website ! Will try to apply all your advice on my website : loto résultats and return here if i have questions !
#
This article is something that will help me with my class assignment. It helped me to better understand another aspect of this topic. Thanks. Cara agar cepat hamil and Iconia PC tablet dengan Windows 8 Acer.
#
thats the code i was looking for a while back. Visit my web site for more where that came from.
#
I'm new on this platform, and looks to translate suffered, finally found the solution, it worked in my project, and honestly was not that difficult, but the habit of working on other platforms just disturbing when we migrated to new, thanks for sharing ! http://massagemalternativa.blogspot.com.br
#
I'm new on this platform, and looks to translate suffered, finally found the solution, it worked in my project, and honestly was not that difficult, but the habit of working on other platforms just disturbing when we migrated to new, thanks for sharing !
#
Who knows how to modify this script to work with the Twitter API?
#
I want to use this script with facebook ? is it possible to do that on my website 1panneau-solaire ?
#
Thank you so much fot this script. try on my localhost test hope this work for me. cara menurunkan berat badan
#
ijin nampang dimari [HTML_REMOVED]soal ulangan sd[HTML_REMOVED]
#
Seni adalah tips cepat hamil berbagai macam kegiatan manusia dan produk dari kegiatan-kegiatan tersebut, artikel ini berfokus terutama pada seni visual, yang meliputi penciptaan gambar atau objek dalam bidang termasuk lukisan, soal ulangan sd patung, seni grafis, fotografi, dan media visual lainnya. Arsitektur sering dimasukkan sebagai salah satu seni visual, namun, seperti seni dekoratif, melibatkan penciptaan benda mana pertimbangan praktis penggunaan sangat penting-dengan cara yang mereka biasanya tidak untuk sebuah lukisan, misalnya. Musik, teater, film, tari, dan seni pertunjukan lainnya, serta sastra, dan media lain seperti media interaktif termasuk dalam definisi yang lebih luas dari seni atau seni. [1] Sampai abad ke-17, belajar bahasa inggris seni disebut keterampilan apa pun atau penguasaan dan tidak dibedakan dari kerajinan atau ilmu, tetapi dalam penggunaan modern seni rupa, di mana pertimbangan estetika adalah hal yang terpenting, dibedakan dari keterampilan yang diperoleh secara umum, dan seni dekoratif atau diterapkan.
#
Autodidacticism (juga autodidactism) adalah kursus teknisi komputer self-directed learning yang berhubungan dengan tetapi berbeda dari pembelajaran informal. Dalam arti, autodidacticism adalah "belajar sendiri" atau "sendiri", dan otodidak adalah guru-diri. dimana lagi Autodidacticism adalah kontemplatif, proses menyerap. Beberapa autodidak menghabiskan banyak waktu meninjau sumber daya perpustakaan dan situs pendidikan. Satu dapat menjadi otodidak di hampir setiap titik dalam kehidupan seseorang. Sementara beberapa mungkin telah diberitahu dengan cara konvensional dalam bidang tertentu, mereka dapat memilih kursus bahasa inggris murah untuk menginformasikan diri lainnya, sering tidak berhubungan daerah. Autodidak terkenal termasuk Abraham Lincoln (presiden AS), Srinivasa Ramanujan (matematika), Michael Faraday (ahli kimia dan fisika), Charles Darwin (naturalis), Thomas Alva Edison (penemu), Tadao Ando (arsitek), George Bernard Shaw (dramawan), Frank Zappa (komposer, rekaman insinyur, sutradara film), dan Leonardo da Vinci (insinyur, ilmuwan, matematikawan).
#
Django makes a programmers life much easier!!
designer jewelry CHEAP CAR INSURANCE CAR INSURANCE POLICY CAR INSURANCE POLICY
CAR INSURANCE
CAR INSURANCE
CAR INSURANCE
CAR INSURANCE
CAR INSURANCE
CAR INSURANCE
CAR INSURANCE
CAR INSURANCE
CAR INSURANCE
CAR INSURANCE
GET BEST CAR INSURANCE
GET BEST CAR INSURANCE
CAR INSURANCE
CAR INSURANCE
CAR INSURANCE
CAR INSURANCE
TOP CAR INSURANCE
CAR INSURANCE COMPARISON CAR INSURANCE COMPARISONS CAR INSURANCE COMPANIES VEHICLE INSURANCE
#
I bookmarked this right away, not easy to find Django resources online.
designer jewelry CHEAP CAR INSURANCE CAR INSURANCE POLICY CAR INSURANCE POLICY
CAR INSURANCE
CAR INSURANCE
CAR INSURANCE
CAR INSURANCE
CAR INSURANCE
CAR INSURANCE
CAR INSURANCE
CAR INSURANCE
CAR INSURANCE
CAR INSURANCE
GET BEST CAR INSURANCE
GET BEST CAR INSURANCE
CAR INSURANCE
CAR INSURANCE
CAR INSURANCE
CAR INSURANCE
TOP CAR INSURANCE
CAR INSURANCE COMPARISON CAR INSURANCE COMPARISONS CAR INSURANCE COMPANIES VEHICLE INSURANCE
#
Perlunya pemahaman yang baik dalam bisnis property menuntut kita untuk senantiasa berinovasi jika ingin sukses dalam bisnis yang satu ini. Kegagalan yang terjadi bisa disebabkan oleh beragam faktor yang ditemui dilapangan. Tidak menutup kemungkinan semua akan teratasi jika kita paham teori yang diajarkan bapak cipto pakar property. cipto junaedy teory Cara cepat belajar bahasa inggris cipto junaedy teory Cipto Junaedy tanpa utang, bahkan anda bisa memilikinya sampai lebih dari yang anda bayangkan, Selain itu anda harus menguasai Percakapan bahasa inggris Kemungkinan ataupun peluang untuk memperluas bisnis yang sedang anda geluti akan semakin terbuka lebar tatkala anda bisa menguasai bahasa inggris dengan baik. Tak jarang anda akan mendapatkan relasi bisnis dari mancanegara ysang lebih luas cakupannya.
#
Thanks for this snippets, it really helpful for me. I have bookmark this pages.
suplemen fitness espresso coffee maker
#
Very helpful, Fire Eagle snippet is the exactly what I need right now. Many thanks!
teknik sipil
#
Quality [butik online] (http://www.uniqueoutletonline.com/), and also [baju couple] (http://www.gudangcouple.com/) I should tell you that your blog articles and other content is extremely great. It truly is not simple to retain this kind of top quality in the webpage.
#
This is a great resource for me. Thanks admin http://www.chaviori.com
#
I want to use this script with facebook ? is it possible to do that on my website. jual lingerie. There are many things you should know about butik online and baju couple. And here you can learn many thing about that, such hijab store and bibit sayuran
#
Sunglasses are the necessary [HTML_REMOVED]fake oakley sunglasses[HTML_REMOVED] accessory in daily life,[HTML_REMOVED]fake oakleys[HTML_REMOVED] to protect your eyes, to be more fashion [HTML_REMOVED]replica oakley sunglasses[HTML_REMOVED] in the street, With its excellent lens [HTML_REMOVED]replica oakleys[HTML_REMOVED] technology and strong [HTML_REMOVED]oakley sunglasses sale[HTML_REMOVED] innovation and technology support.
#
Sunglasses are the necessary [url=http://www.fakesunglassesreplicasale.com/]fake oakley sunglasses[/url] accessory in daily life,[url=http://www.fakesunglassesreplicasale.com/]fake oakleys[/url] to protect your eyes, to be more fashion [url=http://www.fakesunglassesreplicasale.com/]replica oakley sunglasses[/url] in the street, With its excellent lens [url=http://www.fakesunglassesreplicasale.com/]replica oakleys[/url] technology and strong [url=http://www.fakesunglassesreplicasale.com/]oakley sunglasses sale[/url] innovation and technology support.
#
I just started to use rich snippets to enhance my Orlando accident attorney website with Google. Do we know if django snippets are recognized by Google yet? They appear to be easier to use then schema.org.
#