Skip to content
This repository was archived by the owner on Dec 4, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions EpiCurl.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function __construct()
'url' => CURLINFO_EFFECTIVE_URL
);
}

public function addEasyCurl($ch)
{
$key = $this->getKey($ch);
Expand All @@ -42,6 +42,16 @@ public function addEasyCurl($ch)
$this->startTimer($key);
return new EpiCurlManager($key);
}

// simplifies example and allows for additional curl options to be passed in via array
public function addURL($url,$options=array()) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
foreach($options as $option=>$value) {
curl_setopt($ch, $option, $value);
}
return $this->addCurl($ch);
}

public function addCurl($ch)
{
Expand Down Expand Up @@ -71,7 +81,7 @@ public function getResult($key = null)
{
if($key != null)
{
if(isset($this->responses[$key]))
if(isset($this->responses[$key]['data']))
{
return $this->responses[$key];
}
Expand All @@ -82,7 +92,7 @@ public function getResult($key = null)
usleep(intval($outerSleepInt));
$outerSleepInt = intval(max(1, ($outerSleepInt*$this->sleepIncrement)));
$ms=curl_multi_select($this->mc, 0);
if($ms > 0)
if($ms >= CURLM_CALL_MULTI_PERFORM)
{
do{
$this->execStatus = curl_multi_exec($this->mc, $this->running);
Expand All @@ -102,7 +112,12 @@ public function getResult($key = null)
}
return false;
}


public function cleanupResponses()
{
$this->responses = array();
}

public static function getSequence()
{
return new EpiSequence(self::$timers);
Expand Down Expand Up @@ -138,7 +153,7 @@ private function storeResponses()
$this->storeResponse($done);
}
}

private function storeResponse($done, $isAsynchronous = true)
{
$key = $this->getKey($done['handle']);
Expand All @@ -156,7 +171,7 @@ private function storeResponse($done, $isAsynchronous = true)
curl_multi_remove_handle($this->mc, $done['handle']);
curl_close($done['handle']);
}

private function startTimer($key)
{
self::$timers[$key]['start'] = microtime(true);
Expand Down
27 changes: 21 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
{
"name": "jmathai/twitter-async",
"description": "Twitter-async is a high performance wrapper for Twitter's OAuth API which provides parallel/asynchronous calls.",
"homepage": "http://www.jaisenmathai.com/articles/twitter-async-documentation.html",
"author": "Jaisen Mathai",
"license": "BSD"
}
"name": "jmathai/twitter-async",
"description": "Twitter-async is a high performance wrapper for Twitter's OAuth API which provides parallel/asynchronous calls.",
"homepage": "http://www.jaisenmathai.com/articles/twitter-async-documentation.html",
"authors": [
{
"name": "Jaisen Mathai",
"homepage": "http://www.jaisenmathai.com/",
"email": "jaisen@jmathai.com",
"role": "Developer"
}
],
"license": "BSD-3-Clause",
"require": {
"ext-curl": "*"
},
"autoload": {
"classmap": [""],
"exclude-from-classmap": ["**/tests/**"]
},
"minimum-stability": "dev"
}