Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to track tweets based on location(s) #16

Merged
merged 2 commits into from
Jan 20, 2018

Conversation

JonasDoebertin
Copy link
Contributor

This adds a wrapper around Phirehose::setLocations($boundingBoxes) called PublicStream::whenFrom($boundingBoxes, $callback).

This allows you to track Tweets by location filtered by one or more bounding boxes.

Track all tweets from San Francisco or New York:

PublicStream::create($accessToken, $accessTokenSecret, $consumerKey, $consumerSecret)
    ->whenFrom([
        [-122.75, 36.8, -121.75, 37.8], // San Francisco
        [-74, 40, -73, 41],             // New York
    ], function(array $tweet) {
        echo "{$tweet['user']['screen_name']} just tweeted {$tweet['text']} from SF or NYC";
    })->startListening();

Track all tweets with a location (from all over the world):

PublicStream::create($accessToken, $accessTokenSecret, $consumerKey, $consumerSecret)
    ->whenFrom([
        [-180, -90, 180, 90] // Whole world
    ], function(array $tweet) {
        echo "{$tweet['user']['screen_name']} just tweeted {$tweet['text']} with a location attached";
    })->startListening();

@freekmurze
Copy link
Member

Nice, could you also add an example to the readme?

@JonasDoebertin
Copy link
Contributor Author

Sure! Coming up later...

@JonasDoebertin
Copy link
Contributor Author

I have added the above examples to the readme. Sorry for being so late.

@freekmurze
Copy link
Member

No need to be sorry, there are no deadlines for contributors. Thanks for investing your time in this package.

@freekmurze freekmurze merged commit b40c9cd into spatie:master Jan 20, 2018
@freekmurze
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants