2013-09-16 81 views

回答

1

并行请求工作完全在SDK一样纯狂饮和不采取MultiCurl的优势。例如,你可以做这样的事情:

$message = 'Hello, world!'; 
$publishCommands = array(); 
foreach ($topicArns as $topicArn) { 
    $publishCommands[] = $sns->getCommand('Publish', array(
     'TopicArn' => $topicArn, 
     'Message' => $message, 
    )); 
} 

try { 
    $successfulCommands = $sns->execute($publishCommands); 
    $failedCommands = array(); 
} catch (\Guzzle\Service\Exception\CommandTransferException $e) { 
    $successfulCommands = $e->getSuccessfulCommands(); 
    $failedCommands = $e->getFailedCommands(); 
} 

foreach ($failedCommands as $failedCommand) { /* Handle any errors */ } 

$messageIds = array(); 
foreach ($successfulCommands as $successfulCommand) { 
    $messageIds[] = $successfulCommand->getResult()->get('MessageId'); 
} 

// Also Licensed under version 2.0 of the Apache License. 

AWS SDK for PHP User Guide有大约以这种方式与命令对象的详细信息。

+0

谢谢!这很棒! – SteveMc