getting the search topic in $stream->setTrack() from which we got a particular tweet?

82 views
Skip to first unread message

nano byte

unread,
Dec 14, 2013, 1:55:33 PM12/14/13
to 140dev-twitt...@googlegroups.com
Hi, 

I'm using "get_tweets.php"  to get the tweets of an array of search topics as follows:

$stream->setTrack($arr_tracks);

Where we can have as you know up to 400 different tracks.  

Well my question is in relation to the processing of that information after we already have the tweets in the table "jason_cache".  


Is there anyway for us to determine the search topic in "$arr_tracks" for which we got a particular tweet?  

example:  

 $stream->setTrack('apple','orange','pear');   and that gives me an x amount of tweets.   How do I determine that tweet 1 was talking about "orange" and tweet #2 was pear?

The obvious way would be to parse the tweet, but is there any other way?   I was thinking that maybe Twitter would give that information in the tweet object it returns.

thank you so much!
 

Adam Green

unread,
Dec 15, 2013, 11:36:40 AM12/15/13
to 140dev-twitt...@googlegroups.com
Parsing each tweet is the only way to identify the keyword, or keywords, that caused it to be returned by the API. The API does not return that information. 


--
You received this message because you are subscribed to the Google Groups "140dev Twitter Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to 140dev-twitter-fra...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Adam Green
CEO, 140dev.com
CTO, UniteBlue.com
ad...@140dev.com
781-879-2960
@140dev

nano byte

unread,
Dec 19, 2013, 10:44:37 AM12/19/13
to 140dev-twitt...@googlegroups.com, ad...@140dev.com
Thank you, Adam.

Alex Saidani

unread,
Jun 29, 2014, 1:32:07 AM6/29/14
to 140dev-twitt...@googlegroups.com, ad...@140dev.com
Bit late to the crowd, but have you got an example of associating a particular post in the database with a particular filter keyword. I'm not entirely sure how to parse it correctly.

Thanks


On Sunday, December 15, 2013 4:36:40 PM UTC, Adam Green wrote:
Parsing each tweet is the only way to identify the keyword, or keywords, that caused it to be returned by the API. The API does not return that information. 
On Sat, Dec 14, 2013 at 1:55 PM, nano byte <nano...@gmail.com> wrote:
Hi, 

I'm using "get_tweets.php"  to get the tweets of an array of search topics as follows:

$stream->setTrack($arr_tracks);

Where we can have as you know up to 400 different tracks.  

Well my question is in relation to the processing of that information after we already have the tweets in the table "jason_cache".  


Is there anyway for us to determine the search topic in "$arr_tracks" for which we got a particular tweet?  

example:  

 $stream->setTrack('apple','orange','pear');   and that gives me an x amount of tweets.   How do I determine that tweet 1 was talking about "orange" and tweet #2 was pear?

The obvious way would be to parse the tweet, but is there any other way?   I was thinking that maybe Twitter would give that information in the tweet object it returns.

thank you so much!
 

--
You received this message because you are subscribed to the Google Groups "140dev Twitter Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to 140dev-twitter-framework+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Alex Saidani

unread,
Jun 29, 2014, 1:32:12 AM6/29/14
to 140dev-twitt...@googlegroups.com

Adam Green

unread,
Jun 29, 2014, 6:04:57 AM6/29/14
to 140dev-twitt...@googlegroups.com


To unsubscribe from this group and stop receiving emails from it, send an email to 140dev-twitter-fra...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Alex Saidani

unread,
Jun 29, 2014, 12:16:04 PM6/29/14
to 140dev-twitt...@googlegroups.com, ad...@140dev.com
Thanks for the response, I don't think that's quite what I mean. 

If i've got the filter rules recipe, book, pizza in the get results track array, and a tweet comes through with the word recipe, I want to stick that in the tweets database with the keyword recipe in another column named keyword, with all the other tweet details.

Is that what the new script actually does?

Thanks.

On Sunday, June 29, 2014 11:04:57 AM UTC+1, Adam Green wrote:
On Sun, Jun 29, 2014 at 1:32 AM, Alex Saidani <al...@saidani.co.uk> wrote:
Bit late to the crowd, but have you got an example of associating a particular post in the database with a particular filter keyword. I'm not entirely sure how to parse it correctly.

Thanks


On Sunday, December 15, 2013 4:36:40 PM UTC, Adam Green wrote:
Parsing each tweet is the only way to identify the keyword, or keywords, that caused it to be returned by the API. The API does not return that information. 
On Sat, Dec 14, 2013 at 1:55 PM, nano byte <nano...@gmail.com> wrote:
Hi, 

I'm using "get_tweets.php"  to get the tweets of an array of search topics as follows:

$stream->setTrack($arr_tracks);

Where we can have as you know up to 400 different tracks.  

Well my question is in relation to the processing of that information after we already have the tweets in the table "jason_cache".  


Is there anyway for us to determine the search topic in "$arr_tracks" for which we got a particular tweet?  

example:  

 $stream->setTrack('apple','orange','pear');   and that gives me an x amount of tweets.   How do I determine that tweet 1 was talking about "orange" and tweet #2 was pear?

The obvious way would be to parse the tweet, but is there any other way?   I was thinking that maybe Twitter would give that information in the tweet object it returns.

thank you so much!
 

--
You received this message because you are subscribed to the Google Groups "140dev Twitter Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to 140dev-twitter-framework+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Adam Green
CEO, 140dev.com
CTO, UniteBlue.com

--
You received this message because you are subscribed to the Google Groups "140dev Twitter Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to 140dev-twitter-framework+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Adam Green

unread,
Jun 29, 2014, 12:18:33 PM6/29/14
to 140dev-twitt...@googlegroups.com
Yes:
"After the tweet and user are added to the database, we can insert a row in the tweet_words table for each collection word found."


To unsubscribe from this group and stop receiving emails from it, send an email to 140dev-twitter-fra...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Alex Saidani

unread,
Jun 29, 2014, 12:38:32 PM6/29/14
to 140dev-twitt...@googlegroups.com, ad...@140dev.com
I see what you mean, but i'm talking about associating a tweet id with what particular rule. So my rules would only have one word, that word needs to be associated with a particular tweet, doesn't matter if there's five tweets with 'recipe' in the filter  column of the tweets table and 100 with the word 'book'. It's simply to be able to query the tweets table for a particular rule as we're sticking them all in a single table regardless of rule.
For more options, visit https://groups.google.com/d/optout.



--

--
You received this message because you are subscribed to the Google Groups "140dev Twitter Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to 140dev-twitter-framework+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Saidani

unread,
Jun 29, 2014, 12:41:38 PM6/29/14
to 140dev-twitt...@googlegroups.com, ad...@140dev.com
The filter column being something i've added to store the keyword through which the tweet was found.

Adam Green

unread,
Jun 29, 2014, 12:41:44 PM6/29/14
to 140dev-twitt...@googlegroups.com
You are welcome to change the code and database in any way you wish. This is open source. It is written with the most generalized architecture, which is a normalized database. 


To unsubscribe from this group and stop receiving emails from it, send an email to 140dev-twitter-fra...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Alex Saidani

unread,
Jun 29, 2014, 5:31:59 PM6/29/14
to 140dev-twitt...@googlegroups.com, ad...@140dev.com
Thanks, I believe there is a slight error in the get_tweets_keyword.php script on http://140dev.com/twitter-api-programming-blog/streaming-api-enhancements-part-3-collecting-tweets-based-on-table-of-keywords/


As below, you've added "WHERE words <> ''" to the SQL statement.

// Build an array of keywords for tweet collection
  public function get_keywords() {
    $query = "SELECT words
  	FROM collection_words
        WHERE words <> ''";
    $result = $this->oDB->select($query);

However when you go on to explain each section of the code you give the following code:

// Build an array of keywords for tweet collection
  public function get_keywords() {
    $query = "SELECT words
  	FROM collection_words";
    $result = $this->oDB->select($query);

Alex Saidani

unread,
Jun 29, 2014, 5:34:14 PM6/29/14
to 140dev-twitt...@googlegroups.com, ad...@140dev.com
Actually I see what's being done, but is it not the point of the out_words column in the database to handle this?

Adam Green

unread,
Jun 29, 2014, 5:45:23 PM6/29/14
to 140dev-twitt...@googlegroups.com
It would probably be best to read all 5 blog posts on this subject starting here:

If you have any questions after studying all of this code and the supporting docs, let me know. 


On Sun, Jun 29, 2014 at 5:34 PM, Alex Saidani <al...@saidani.co.uk> wrote:
Actually I see what's being done, but is it not the point of the out_words column in the database to handle this?

--
You received this message because you are subscribed to the Google Groups "140dev Twitter Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to 140dev-twitter-fra...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages