Actually having some good luck with Twython today.  I figured out that I'm
getting a dict of lists of dicts, so I just had to work with the nesting to
get out the tweet info.  Code is below if you are interested - not as
painful as my previous starter code.  I need to move on to something else
for the moment, but to complete the picture, I realize that I will either
need to start collecting from the streaming API (will need that anyway) or
find a way to get more than 100 tweets in a search to create my baseline.
Will look more again tonight to try and get some data rolling overnight.


----------------------------------------------------------------------


# initiating oauth2 from
https://twython.readthedocs.org/en/latest/usage/starting_out.html
from twython import Twython

APP_KEY = "<my key>"
APP_SECRET = "<my secret>"

twitter = Twython(APP_KEY, APP_SECRET, oauth_version=2)
ACCESS_TOKEN = twitter.obtain_access_token()

twitter = Twython(APP_KEY, access_token=ACCESS_TOKEN)

# see search options here:
https://dev.twitter.com/docs/api/1.1/get/search/tweets
response = twitter.search(q="marriott",count=100,result_type="recent")

# response is a dict with two keys - 'search_metadata' and 'statuses'
# response['statuses'] is a list of length # of tweets requested - each is
a dict for the tweets
# therefore, in loop below, each x is a dict, key 'text' gives the text of
the tweets
# more doc on the dict of each tweet is here:
https://dev.twitter.com/docs/platform-objects/tweets

for x in response['statuses']:
  print x['text']




On Sun, Mar 30, 2014 at 1:46 PM, Holly Waisanen-Hatipoglu <
holly.a.wh@gmail.com> wrote:

> I'm struggling with Twython right this moment.  I used oauth2 and some
> starter code to do a similar exercise about a year ago for a Coursera
> course, but Twitter's API has changed and apparently oauth2 isn't the most
> up to date library. So far, I can authenticate and query the search API to
> get a dict with two entries with info on 15 tweets buried within one of the
> values, but that's not quite what I need yet.
>
> Any recommendations for a more direct methodology?  Copied Tommy here too
> since I emailed with him a tiny bit about this last night.
>
> Thanks,
> Holly
>
>
>
> On Sun, Mar 30, 2014 at 1:18 PM, Aaron Schumacher <
> notifications@github.com> wrote:
>
>> In 06-naive_bayes/elevator/hollytwitterhotelsproject.md:
>>
>> > @@ -0,0 +1,21 @@
>> > +Social media and brand marketing for the hotel industry
>> > +========================================================
>> > +
>> > +Brands are increasingly looking to build a deeper engagement with their customers and view social media an opportunity to create ongoing conversations about the brand, its products, and the customers' needs and wants.  Some brand conversations are initiated by customers, usually revolving around customer service or reviews.  Other conversations are initiated by brand marketing organziations and try to drum up buzz around existing marketing programs or new campaigns developed specifically for social channels.  This study will examine this second kind of conversation and attempt to understand the effectiveness of brand led campaigns at generating this buzz and fostering genuine customer response.
>> > +
>> > +In this study, we will look at how the top brands in the hotel industry are using Twitter and attempt to measure the customer response.  In the case that brands are pushing marketing-specific hashtags or initiating campaigns, we will quantify who is using these hashtags and attempt to derive sentiment.  In parallel, we will also gather Twitter data for all references to a few selected brands (not just promotional hashtags) and again attempt to quantify who is driving the conversations (brands, hotels, or customers), which conversations gain traction, and derive overall sentiment.
>> > +
>> > +This study will document a variety of data handling and machine learning techniques, coupled with manual inspection for categorization.  First step is to understand and set up a feed to the Twitter JSON API, possibly on an AWS instance for full time data capture.  Data will be analyzed in Python, likely using the NLTK package.  I am also interested to explore other Natural Language Processing packages (e.g. Google's word2vec, others?), and will need to determine a training corpus to use to determine the positivity or negativity of words in Twitter.  Plotting may be run in R or Python.
>> > +
>> > +I will be interested in determining other appropriate unsupervised learning techniques to make sense of the data, but need to research further once I have the data pulls in progress.
>> > +
>> > +
>> > +### Tactical planning as of 29 March 2014
>> > +
>> > +1) Week of Mar 30 - Determine official twitter accounts for brand and loyalty programs for five top full service hotel brands (Marriott, Hilton, Hyatt, Sheraton, Holiday Inn).  Collect and review one week of tweets and extract hashtags.  Identify promotional hashtags (e.g. #BeAWeekender, #TravelBrilliantly) and top brand twitter accounts to follow longer term by April 6.
>>
>> @dblosqrl <https://github.com/dblosqrl> Hi! Do you have a method for
>> collecting tweets already?
>>
>> --
>> Reply to this email directly or view it on GitHub<https://github.com/ajschumacher/gadsdc1/pull/81/files#r11099043>
>> .
>>
>
>