foreach ($Model1['PlatformApplications'] as $App) { print $App['PlatformApplicationArn'] . "\n"; } print "\n"; // Get the Arn of the first application $AppArn = $Model1['PlatformApplications'][0]['PlatformApplicationArn']; // Get the application's endpoints $Model2 = $sns->listEndpointsByPlatformApplication(array('PlatformApplicationArn' => $AppArn)); // Display all of the endpoints for the first application print "List All Endpoints for First App:\n"; //$Endpoint = []; foreach ($Model2['Endpoints'] as $Endpoint) { $EndpointArn = $Endpoint['EndpointArn']; print $EndpointArn . "\n"; } print "\n"; // Send a message to each endpoint print "Send Message to all Endpoints:\n"; foreach ($Model2['Endpoints'] as $Endpoint) { $EndpointArn = $Endpoint['EndpointArn']; try { $sns->publish(array('Message' => 'Hello from PHP', 'TargetArn' => $EndpointArn)); print $EndpointArn . " - Succeeded!\n"; } catch (Exception $e) { print $EndpointArn . " - Failed: " . $e->getMessage() . "!\n"; } } } } } }