Created
October 17, 2010 08:54
-
-
Save fprochazka/630675 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Curl\MultiRequest; | |
use Curl\Request; | |
$testMulti = new MultiRequest($config); | |
# create request | |
$testMulti['prevodnik'] = new Request("http://curl.kdyby.org/prevodnik.asm.zdrojak"); | |
$testMulti['kdyby'] = new Request("http://www.kdyby.org/"); | |
# read | |
foreach ($testMulti as $name => $response) { // nevrací v pořadí, ale jak příjdou (inteligentní iterator) | |
echo "<h2>{$name}</h2>"; | |
echo "<h3>Response headers:</h3>"; | |
dump($response->getHeaders()); | |
echo "<h3>Response:</h3>", "<pre>"; | |
var_dump(htmlspecialchars($response->getResponse())); | |
echo "</pre>"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Tento způsob by šel bez problému zkombinovat s prvním | |
*/ | |
use Curl\MultiRequest; | |
$testMulti = new MultiRequest($config); | |
# create request | |
$testMulti['prevodnik'] = "http://curl.kdyby.org/prevodnik.asm.zdrojak"; | |
$testMulti['kdyby'] = "http://www.kdyby.org/"; | |
$testMulti->onResponse[] = function($response, $request, $name) { | |
echo "<h2>{$name}</h2>"; | |
echo "<h3>Response headers:</h3>"; | |
dump($response->getHeaders()); | |
echo "<h3>Response:</h3>", "<pre>"; | |
var_dump(htmlspecialchars($response->getResponse())); | |
echo "</pre>"; | |
}; | |
# read | |
$testMulti(); // OR $testMulti->readResponse(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Curl\MultiRequest; | |
use Curl\Request; | |
$testMulti = new MultiRequest($config); | |
# create request | |
$testMulti->addRequest('prevodnik', "http://curl.kdyby.org/prevodnik.asm.zdrojak"); | |
$testMulti->addRequest('kdyby', "http://www.kdyby.org/"); | |
# read | |
foreach ($testMulti as $name => $response) { // nevrací v pořadí, ale jak příjdou (inteligentní iterator) | |
echo "<h2>{$name}</h2>"; | |
echo "<h3>Response headers:</h3>"; | |
dump($response->getHeaders()); | |
echo "<h3>Response:</h3>", "<pre>"; | |
var_dump(htmlspecialchars($response->getResponse())); | |
echo "</pre>"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Curl\MultiRequest; | |
use Curl\Request; | |
$testMulti = new MultiRequest($config); | |
# create request | |
$testMulti->addRequest('prevodnik', "http://curl.kdyby.org/prevodnik.asm.zdrojak", function($response, $request, $name){ | |
echo $response->guery['title']->contents(); | |
}); | |
$testMulti->addRequest('kdyby', "http://www.kdyby.org/" function($response, $request, $name){ | |
echo $response->guery['body .article:first p']->contents(); | |
}); | |
# read | |
$testMulti(); // OR $testMulti->readResponse(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment