echo $aux->get('PlatformApplicationArn').'<br>'; $aux = $sns->createPlatformEndpoint(array( // PlatformApplicationArn is required 'PlatformApplicationArn' => $aux->get('PlatformApplicationArn'), // Token is required 'Token' => 'dp836ywq5ME:APA91bGhHu-imZjWrGQZoOqt-N5vthihQquLy0dQm6ENSDlNvFlk6nWnJwjPYnymF0PGmGiKNTWdIkpVo1GqEwZVMfZ4skjmYlngMo9k8iPuQVjTr4zUg7LSKUKKFmTQQJv9P9viWGqk', //'CustomUserData' => 'string', 'Attributes' => array( // Associative array of custom 'String' key names 'Enabled' => 'true' ), )); echo $aux->get('EndpointArn').'<br>';*/ $sns = new AwsSns(); echo $sns->getEndpointArn('dp836ywq5ME:APA91bGhHu-imZjWrGQZoOqt-N5vthihQquLy0dQm6ENSDlNvFlk6nWnJwjPYnymF0PGmGiKNTWdIkpVo1GqEwZVMfZ4skjmYlngMo9k8iPuQVjTr4zUg7LSKUKKFmTQQJv9P9viWGqk'); echo '<br><br>'; // Get and display the platform applications print "List All Platform Applications:\n"; $Model1 = $sns->listPlatformApplications(); 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";
public static function sendMessageRemoved_AwsSns($message, $userFrom, $userTo) { // GCM SENDER $client = new AwsSns(); $data = ['data' => ['type' => '3', 'id' => "" . $message->id, 'userFrom_id' => "" . $userFrom->id, 'userTo_id' => "" . $userTo->id], 'collapse_key' => 'messageRemoved', 'delay_while_idle' => 'false', 'time_to_live' => "" . 4 * 7 * 24 * 60 * 60, 'restricted_package_name' => 'br.com.thiengo.gcmexample', 'dry_run' => 'false']; $dataGcm = ['TargetArn' => $client->getEndpointArn($userFrom->registrationId), 'MessageStructure' => 'json', 'Message' => json_encode(['GCM' => json_encode($data)])]; $result = $client->sns->publish($dataGcm); try { if (!empty($userTo->registrationId)) { $dataGcm['TargetArn'] = $client->getEndpointArn($userTo->registrationId . '654946546456875'); // .'654946546456875' $client->sns->publish($dataGcm); } } catch (Exception $e) { if (substr_count($e->getMessage(), "InvalidParameter") > 0) { $userTo->registrationId = ''; CgdUser::updateRegistrationId($userTo); } Util::generateFile($e->getCode() . ' |||| ' . $e->getMessage()); } }