I am using Amazon's php sdk.
I use Amazon SNS service to send direct sms. When I send an sms from my php application it gives me a message ID.
I have to track the delivery status of each of my message. I have enabled cloud watch logs for Text Messaging using Manage text messaging preferences settings. The IAM role is properly configured and logs end in Cloudwatch.
Now the problem I am facing is that the system creates a random log stream for every message i send.
Here is a screen shot.
I have sent six messages and all of them has been successful( I am sending them to myself). And against every message a single log stream exists.
API gives me a function to get logs based upon LogGroupName and LogGroupStream. The LogGroupName remains the same but LogGroupStream is differnt for every message.
here is the sdk call
$result = $client->getLogEvents([
'endTime' => <integer>,
'limit' => <integer>,
'logGroupName' => '<string>', // REQUIRED
'logStreamName' => '<string>', // REQUIRED
'nextToken' => '<string>',
'startFromHead' => true || false,
'startTime' => <integer>,
]);
How should i get the Logs? Is there a way to tell amazon to log all of sms deliveries to a single LOG STREAM. So i know the stream and can query for logs.
With a Query:
$result = $CloudWatchclient->startQuery([
'endTime' => strtotime("+5 minutes", strtotime($creation_date)) * 1000,
'limit' => 1,
'logGroupName' => '.....DirectPublishToPhoneNumber',
'queryString' => 'field #message like /'.$awsmessageid.'/',
'startTime' => strtotime($creation_date)*1000,
]);
$queryid = $result->get('queryId');
sleep(2);
$result = $CloudWatchclient->getQueryResults([
'queryId' => $queryid, // REQUIRED
]);
$result = $result->get('results');
The result containt the event log with sms data success
You could use filterLogEventsMethod from CloudWatchLogsClient:
$result = $client->filterLogEvents(array(
'logGroupName' => 'string', //Required
'startTime' => integer,
'endTime' => integer,
'filterPattern' => 'string',
'nextToken' => 'string',
'limit' => integer,
'interleaved' => true || false));
Reference: Aws Docs
Related
I have two questions
One:
What values can we send to Stripe using Omnipay authorize(), example below is only sending amount and description
$response = $gateway->authorize([
'amount' => '10.00',
'currency' => 'USD',
'description' => 'This is a test purchase transaction.',
'paymentMethod' => $paymentMethod,
'returnUrl' => $completePaymentUrl,
'confirm' => true,
])->send();
what if we want name and email to be sent, how can we achieve this also
Two:
the payment intent we get back from the above request, is generating error log on Godaddy server, I am using the following code;
$paymentIntentReference = $response->getPaymentIntentReference();
$response = $gateway->confirm([
'paymentIntentReference' => $paymentIntentReference,
'returnUrl' => $completePaymentUrl,
])->send();
error log: PHP Fatal error: Uncaught Omnipay\Common\Exception\InvalidRequestException: The paymentIntentReference parameter is required
by my confusion is that in spite of this error log the payment process is being complete, so should I worry about this error or not,
and I hope this time I asked my question in the right manner
thanks in advance
I have few doubts regarding sending SNS Push Notifications.
1) I referred this stackoverflow discussion where we can set sound for APNS. But how we do it for GCM ?
2) How to configure no sound alert ?
3) Is it possible to set sound for each Endpoint in PHP while creating them ? I just want to know this so that while sending message I can send to those with sound enabled and to those disabled while sending it with topicARN.
4) I referred this document for getting the delivery status of push notification as logs in cloudwatch. Is there any API to retrieve the delivery status of those endpoints which failed to receive in PHP ?
For GCM, you can do like this:
$send = $sns->publish(array(
'TargetArn' => $EndpointArn, // to send notification to single user
'MessageStructure' => 'json',
'Message' => json_encode(array(
'default' => '',
'APNS' => json_encode(array(
'aps' => array(
'alert' => 'message to topic',
'sound'=> 'default',
'badge'=> 1
),
'userid' => '1'
)),
'GCM' => json_encode(array(
'data' => array(
'alert' => 'message to topic',
'userid' => '1'
),
))
))
));
Do you want to create a custom sound alert for each endpoint arn?
For 4th point refer this links:
1) http://docs.aws.amazon.com/sns/latest/dg/sns-msg-status.html?ref_=pe_411040_132389510
2) How to confirm delivery status when using amazonSNS mobile push?
I am running into an error attempting to authenticate and create a new Route53 Record Set using the Amazon's PHP SDK and changeresourceRecordSets. Here's what I have attempted so far:
Installed the AWS SDK for Laravel
Used Amazon's IAM to create a new user and group and applied the FullAdministrator policy to the group.
Stored the new user credentials and other AWS variables in my .env file like so:
Code below:
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=XXYYZZ
AWS_SECRET_ACCESS_KEY=112233
AWS_ZONE_ID=UHUHUHUH
Confirmed that my Laravel environment is configured correctly and my controller works by testing the following:
Code below:
$s3 = AWS::createClient('s3');
$s3->putObject(array(
'Bucket' => 'mydomain.com',
'Key' => 'new.pdf',
'SourceFile' => storage_path('app/old.pdf'),
));
Once I confirmed that my credentials worked against S3, I closely followed this SO answer and code to create a new Route53 client and create a new Record Set in my Route53 Hosted Zone. Here's my slightly modified code:
Code below:
$client = AWS::createClient('Route53');
//dd($client); $client object returned, this works
$result = $client->changeResourceRecordSets(array(
'HostedZoneId' => env('AWS_ZONE_ID'),
'ChangeBatch' => array(
'Comment' => 'just testing',
'Changes' => array(
array(
'Action' => 'CREATE',
'ResourceRecordSet' => array(
'Name' => 'test.mydomain.com.',
'Type' => 'A',
'TTL' => 600,
'ResourceRecords' => array(
array(
'Value' => '52.52.52.52',//my AWS IP address
),
),
),
),
),
),
));
The resulting error is as follows:
Client error: POST
https://route53.amazonaws.com/2013-04-01/hostedzone/MYZONE/rrset/
resulted in a 403 Forbidden response:
Sender
And more from the error...
SignatureDoesNotMatch (client): Signature expired: 20160225T215502Z is now earlier than 20160225T220842Z (20160225T221342Z - 5 min.)
Any suggestions are appreciated.
I should have added that I'm running in a homestead/virtualbox environment and the real problem was that my date service on my VM was woefully off.
Simply running sudo ntpdate -s time.nist.gov fixed the problem.
I am attempting to send mail using AWS SES sendEmail method, and I'm having trouble with an error. I have read this question: AWS SDK Guzzle error when trying to send a email with SES
I am dealing with a very similar issue. The original poster indicates that they have a solution, but did not post the solution.
My code:
$response = $this->sesClient->sendEmail('example#example.com',
array('ToAddresses' => array($to)),
array('Subject.Data' => array($subject), 'Body.Text.Data' => array($message)));
Guzzle code producing the error (from aws/Guzzle/Service/Client.php):
return $this->getCommand($method, isset($args[0]) ? $args[0] : array())->getResult();
Error produced:
Catchable fatal error: Argument 2 passed to Guzzle\Service\Client::getCommand() must be of the type array, string given
Looking at the Guzzle code, I can see that the call to getCommand will send a string if args[0] is set and is a string. If args[0] is NOT set then an empty array is sent.
What am I missing here please?
SOLUTION:
It turns out I was trying to use SDK1 data structures on the SDK2 code base. Thanks to Charlie Smith for helping me to understand what I was doing wrong.
For others (using AWS SDK for PHP 2) :
Create the client -
$this->sesClient = \Aws\Ses\SesClient::factory(array(
'key' =>AWS_ACCESS_KEY_ID,
'secret' => AWS_SECRET_KEY,
'region' => Region::US_EAST_1
));
Now, structure the email (don't forget that if you're using the sandbox you will need to verify any addresses you send to. This restriction doesn't apply if you have been granted production status) -
$from = "Example name <example#example.com>";
$to ="example#verified.domain.com";
$subject = "Testing AWS SES SendEmail()";
$response = $this->sesClient->getCommand('SendEmail', array(
'Source' => $from,
'Destination' => array(
'ToAddresses' => array($to)
),
'Message' => array(
'Subject' => array(
'Data' => $subject
),
'Body' => array(
'Text' => array(
'Data' => "Hello World!\n Testing AWS email sending."
),
'Html' => array(
'Data' => "<h1>Hello World!</h1><p>Testing AWS email sending</p>"
)
),
),
))->execute();
That should work now.
Here is the relevant section in the AWS SDK for PHP 2 documentation:
http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.Ses.SesClient.html#_sendEmail
I'm a PHP developer. I've implemented Paypal Mobile Library IPN.
Here is what i receive in test mode.
$_POST = array(
'payment_request_date' => 'Wed Jun 15 07:21:26 PDT 2011',
'return_url' => 'https://www.paypal.com',
'fees_payer' => 'EACHRECEIVER',
'ipn_notification_url' => 'http://mysite.com/myscript.php',
'verify_sign' => 'AsPVXqWsrQkFWs.gl9jI5iQU2b53AiFm-2O-GeHSy9tAKrrPm327E81P',
'test_ipn' => 1,
'transaction' => array('USD 9.99'),
'cancel_url' => 'https://www.paypal.com',
'pay_key' => 'AP-725112792Y356822X',
'action_type' => 'CREATE',
'memo' => '55547098#1 month platinum membership',
'transaction_type' => 'Adaptive Payment PAY',
'status' => 'COMPLETED',
'log_default_shipping_address_in_transaction' => false,
'charset' => 'windows-1252',
'sender_useCredentials' => true,
'notify_version' => 'UNVERSIONED',
'reverse_all_parallel_payments_on_error' => false,
);
As I see there is a field verify_sign, so I guess that it should be verified by sending to
https://www.sandbox.paypal.com/cgi-bin/webscr
following POST request:
$req = 'cmd=_notify-validate&'.http_build_query($_POST);
But it always returns INVALID.
I also tried using SOAP request to GetTransactionDetails for validation of this transaction, asTransactionID I specified $_POST['pay_key'] (AP-725112792Y356822X) and this service returns error
10004 The transaction id is not valid
So how can I verify the Paypal Mobile Library response?
Can i check it's verification in sandbox mode or only on live.
Thank you for any suggestions.
I would recommend trying to use the IPN code sample in PHP on PayPal developer network here: https://www.x.com/developers/PayPal/documentation-tools/code-sample/216623