コード例 #1
0
ファイル: views.py プロジェクト: LasseRegin/djangoTwitter
def get_trends(request):


    import pdb
    import json, numpy as np

    # paramenters are in request.GET

    from django.conf import settings

    # Initialize Api object
    api = twitterApi()

    print 'abe'
    print api
    print 'abe'

    # New York
    WOE_ID = 2459115

    # Get trends
    trends = api.trendsByArea(WOE_ID)

    response_data = {}
    response_data['trends'] = trends

    return HttpResponse(json.dumps(response_data), content_type="application/json")
コード例 #2
0
ファイル: views.py プロジェクト: LasseRegin/djangoTwitter
def get_limits(request):


    import pdb
    import json, numpy as np

    # paramenters are in request.GET

    from django.conf import settings

    # Initialize Api object
    api = twitterApi()

    # Get trends
    limits = api.getApiLimit()

    response_data = {}
    response_data['limits'] = limits

    return HttpResponse(json.dumps(response_data), content_type="application/json")
コード例 #3
0
ファイル: views.py プロジェクト: LasseRegin/djangoTwitter
def tweets_by_message(request):


    import pdb
    import json, numpy as np

    # paramenters are in request.GET

    from django.conf import settings
    #url = settings.STATICFILES_FOLDER + 'data/vocabulary.json'

    #twitterApi
    # Initialize Api object
    api = twitterApi()

    # Tweet message to look for
    message = request.GET['message']

    # New York
    latitude = 40.716667   # latitude in degrees
    longitude = -74.0      # longitude in degrees
    radius    = 20         # radius in km

    today = datetime.now()
    sinceDate = today - timedelta(hours=5)
    #sinceDate = today - timedelta(weeks=1)
    print sinceDate

    # Get tweets
    #tweets = api.tweetsByMessageAndDate(message, latitude, longitude, radius, date)
    tweets = api.tweetsByMessageAndAreaSinceDate(message, latitude, longitude, radius, sinceDate)
    #print 'Found %d matching tweets:' % (len(tweets))
    #print ''

    response_data = {}
    response_data['tweets'] = tweets
    response_data['message'] = message

    return HttpResponse(json.dumps(response_data), content_type="application/json")