def lookup(request): what = (request.POST['what']).lower() where = (request.POST['where']).lower() api = twython.setup('Basic', username='******', password='') gmaps = GoogleMaps() mentions = api.getUserMentions(since_id=4698625520) a = [] lat1, lng1 = gmaps.address_to_latlng(where) #if is not (api): # render_to_response('need/enter.html') for stat in mentions: text = (stat["text"]).lower() ele = text.split(':') lat2 = float(ele[2]) lng2 = float(ele[3]) if (text.find(what) != -1) and (in_vic(lat1, lng1, lat2, lng2) == 1): actual = gmaps.latlng_to_address(lat2, lng2) tweet = ele[1] + " " + actual a.append(tweet) t = loader.get_template("need/results.html") c = Context({'stat': a},) return HttpResponse(t.render(c))
def auth(request): api = twython.setup('Basic', request.POST['user'], request.POST['pass']) if (api): request.session['username'] = request.POST['user'] request.session['password'] = request.POST['pass'] return render_to_response('have/add.html') else: return render_to_response('have/login.html')
def tweet(request): api = twython.setup('Basic', request.session['username'], request.session['password']) gmaps = GoogleMaps() what = request.POST['what'] where = request.POST['where'] lat, lng = gmaps.address_to_latlng(where) tweet = "@U_Need :" + what + ":" + str(lat) + ':' + str(lng) + ":#ihave" api.updateStatus(tweet) return render_to_response('have/add.html')