2013-09-16 108 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