forked from Yaffle/MultiGet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
27 lines (23 loc) · 836 Bytes
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?
require_once "MultiGet_GetInterface.php";
require_once "MultiGet_Get.php";
require_once "MultiGet_RequestInterface.php";
require_once "MultiGet_Request.php";
$hashTags = array('php', 'javascript');
$mget = new MultiGet_Get();
foreach ($hashTags as $tag) {
$url = 'http://search.twitter.com/search.json?q=' . urlencode($tag) . '&rpp=5&include_entities=true&with_twitter_user_id=true&result_type=mixed';
$mget->request($url)
->on('success', function ($content, $url, $handle) use ($tag) {
$x = json_decode($content);
echo '<h1>#' . $tag . '</h1>';
foreach ($x->results as $i => $tweet) {
echo $tweet->text . '<br>';
}
})
->on('error', function ($url, $handle) {
echo 'error while downloading ' . $url;
});
}
$mget->go();
?>