I have do this code in to php file but it will not give any result can anyone help me please. It is not working on amazon ec2 server only for android push notification. Below code is implemented in my php file and i have run it on amazon ec2 server but i could not get any response can someone please help me for this.
require 'aws.phar';
use Aws\Sns\SnsClient;
if(isset($_POST['submit']))
{
$push_message = $_POST['push_message'];
if(!empty($push_message))
{
$sns = SnsClient::factory(array(
'key' => 'AKIAJ4UCJBMTMRVMPFGQ',
'secret' => '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',
'region' => 'us-east-1'
));
$android_AppArn = "arn:aws:sns:us-east-1:052393086922:app/GCM/wergold";
$android_model = $sns->listEndpointsByPlatformApplication(array('PlatformApplicationArn' => $android_AppArn));
// Display all of the endpoints for the android application
foreach ($android_model['Endpoints'] as $endpoint)
{
$endpointArn = $endpoint['EndpointArn'];
echo $endpointArn;
}
// android: Send a message to each endpoint
foreach ($android_model['Endpoints'] as $endpoint)
{
$endpointArn = $endpoint['EndpointArn'];
try
{
$sns->publish(array('Message' => $push_message,
'TargetArn' => $endpointArn));
echo "<strong>Success:</strong> ".$endpointArn."<br/>";
}
catch (Exception $e)
{
echo "<strong>Failed:</strong> ".$endpointArn."<br/><strong>Error:</strong> ".$e->getMessage()."<br/>";
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire