I have subscribed my endpoint and now I need to pull the emailAddress from the object/array I cannot get the value 'fakeemail#
gmail.com' for the life of me
Aws\Sns\Message Object
(
data:Aws\Sns\Message:private => Array
(
Type => Notification
MessageId => hghkvvhhv32hg32vh23v32hjk32bjk
TopicArn => arn:aws:sns:us-west-232jh32bhj322j3hv23jhv23jhv2
Message => {"notificationType":"Bounce","bounce":{"bounceType":"Permanent","bounceSubType":"Suppressed","bouncedRecipients":,"timestamp":"2016-06-21T04:43:05.786Z","feedbackId":"wef-a5166c3e-fe-11e6-923e4-1115qbdde1aq2907d-000000","reportingMTA":"dns; amazonses.com"},"mail":{"timestamp":"2016-06-21T04:43:04.000Z","source":"www-data#myserver.com","sourceArn":"arn:aws:ses:us-west-2:0f2243234320627162:identity/myserver.com","sendingAccountId":"0243122452162","messageId":"0103714433d74e-e3bfd2dd3b3b7-49238-45a3f-953fa-c9a3eb3fd312c-03300000","destination":["fakeemail#
gmail.com"]}}
Timestamp => 2016-06-21T04:43:05.882Z
SignatureVersion => 1
Signature => vfvdfvsdffsvfadvfdvdfvdfdfsdvsdfdf
SigningCertURL => https://sns.us-west-2.amazonaws.com/SimpleNotificationService-vafvadfvadsvdsfdsvsvdsdfsdvsdsvd.pem
UnsubscribeURL => https://sns.us-west-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-west-2:02vsddfvddv43230vfvsvf67162:email_bounce:5fc6vsdfvd6af9-cfssdvdv197-4vfsdf0f-afb7-67fvdfs1b
)
)
I have changed my details above but this is what is given. I need to get the
fakeemail#gmail.com from array in the object but cant for the life of me
//from aws sdk
$message = Message::fromRawPostData();
I used
print_r($message['Message'], true);
to get the data above would be appreciated :)
Ok I figured it out. You want to take the
$message['Message']
and encode it to json to use as an object
$test = json_decode($message['Message']);
$returnsMyAnswer = print_r($test-> mail-> destination[0], true);
and then
echo $returnsMyAnswer;
and you get
fakeemail# gmail.com
Related
I am building a simple SMS sending module with the RingCentral WebRTC client in PHP. I can successcully send messages and I get a valid JSON response object, and when I echo it out I can see the conversationId, but I cannot seem to echo it into a variable.
This is my API call:
$resp = $this->platform->post('/account/~/extension/~/sms',
array(
'from' => array ('phoneNumber' => $this->ringcentral_username),
'to' => array(array('phoneNumber' => $phone)),
'text' => $message
));
I can see:
"conversationId" : 1234567890,
in the response object, but $resp->conversationId is not found. How do I pull that out?
I found it:
$resp->json()->conversationId
I am using API of Xverify for email verifiation
Below is my API code:
require 'XverifyClientAPI.php';
$api_key = 'myapikey'; // Your API Key
$options = array();
$options['type'] = 'json'; // API response type
$options['domain'] = 'addeddomainname';// Reruired your domain name
$client = new XverifyClientAPI($api_key,$options);
$data = array();
$data['email'] = 'test#xverify.com';
$client->verify('email',$data);
echo '<pre>';
echo "valid: ", var_dump($client->is_valid()), "\n";
echo "status: ", $client->status(), "\n";
print_r($client->getReponseAsObject());// Convert the json response into object
Here I have use API key which is provided in my xverify account and domain name which is added in my xverify account
but still its give me error like below
valid: bool(false)
status: bad_request
stdClass Object
(
[syntax] => 1
[handle] => test
[domain] => xverify.com
[catch_all] => unknown
[address] => test#xverify.com
[error] => 0
[status] => bad_request
[responsecode] => 504
[message] => Reach the API Limit
[duration] => 0.013515949249268
)
I am not getting what is the problem with this ,can any body help me ?
Make sure you are using the correct url to call the api, in my case i had to the the domian name us.xverify.com to make it work, before i was using only xverify.com which always gave me the result same as yours(api limit reached), to check the correct api call log in to your xverify account and then click on setting and select email and scroll to the bottom of the page and check the correct url. If the id was created in the us i guess you have to use us.xverify.com
I am trying to send sms messages using Twilio API in Wordpress, but I don't understand what is curl -u. Now I want to send sms using twilio and wordpress via wp_remote_post.
See twilio send sms docs API (via JSON)
My code:
function sending_sms_via_twilio_api(){
$oauth_args = array(
"body" => array(
"Body" => "Hello World",
"To" => "0000000",
"From" => "5555555",
),
"my_Sid:my_token"
);
$response = wp_remote_post('https://api.twilio.com/2010-04-01/Accounts/AC28fcd041ffe3edb8029779894b7912d3/Messages.json', $oauth_args);
$result = json_decode( wp_remote_retrieve_body($response), true );
print_r($result);
}
Result is:
Array ( [code] => 20003 [detail] => Your AccountSid or AuthToken was
incorrect. [message] => Authentication Error - No credentials provided
[more_info] => [status] => 401 )
Any solutions?
That is a simple authentication problem. You should check your credentials again.
A GET call on https://{AccountSid}:{AuthToken}#api.twilio.com/2010-04-01/Accounts with wrong credentials give that problem.
Also the api response give this error page as advice for you:
https://www.twilio.com/docs/errors/20003
Hope it helps
I am trying to implement OAuth2 with Doctrine as an entity manager. I followed this tutorial exactly:
http://bshaffer.github.io/oauth2-server-php-docs/cookbook/doctrine2/
Here is my code that is called when a user makes a request to the API:
// obtaining the entity manager
$entityManager = EntityManager::create($conn, $config);
$clientStorage = $entityManager->getRepository('OAuthClient');
$clients = $clientStorage->findAll();
print_r($clients); // We are getting the clients from the database.
$userStorage = $entityManager->getRepository('OAuthUser');
$accessTokenStorage = $entityManager->getRepository('OAuthAccessToken');
$authorizationCodeStorage = $entityManager->getRepository('OAuthAuthorizationCode');
$refreshTokenStorage = $entityManager->getRepository('OAuthRefreshToken');
//Pass the doctrine storage objects to the OAuth2 server class
$server = new \OAuth2\Server([
'client_credentials' => $clientStorage,
'user_credentials' => $userStorage,
'access_token' => $accessTokenStorage,
'authorization_code' => $authorizationCodeStorage,
'refresh_token' => $refreshTokenStorage,
], [
'auth_code_lifetime' => 30,
'refresh_token_lifetime' => 30,
]);
$server->addGrantType(new OAuth2\GrantType\ClientCredentials($clientStorage));
// handle the request
$server->handleTokenRequest(OAuth2\Request::createFromGlobals())->send();
Whenever a call using the correct credentials is made, I get this response:
Array
(
[0] => OAuthClient Object
(
[id:OAuthClient:private] => 1
[client_identifier:OAuthClient:private] => testclient
[client_secret:OAuthClient:private] => testpass
[redirect_uri:OAuthClient:private] => http://fake.com
[hashOptions:protected] => Array
(
[cost] => 11
)
)
[1] => OAuthClient Object
(
[id:OAuthClient:private] => 2
[client_identifier:OAuthClient:private] => trevor
[client_secret:OAuthClient:private] => hutto
[redirect_uri:OAuthClient:private] => https://www.another.com
[hashOptions:protected] => Array
(
[cost] => 11
)
)
)
{"error":"invalid_client","error_description":"The client credentials are invalid"}
So we are getting the clients from the database, we should be checking them, and returning that they in fact exists and issuing an access token. However, for some reason, OAuth2 Server (can be seen here) can not match the given credentials with the stored credentials.
I do not think this is a Doctrine problem because I can retrieve the results fairly easily using findAll().
My question is:
Why is this happening, and how can I fix it?
I found the problem. In the tutorial (http://bshaffer.github.io/oauth2-server-php-docs/cookbook/doctrine2/) they fail to mention that when the client secret is checked with against a hashed version of the provided client secret.
In the tutorial they do not hash the example client secret when they put it in the database.
If you hash your client secret when inserting it into the database, it will work as expected.
I am trying to set a reminder in a calendar using the Google PHP libraries with this code:
$rem = new Google_EventReminders();
$rem->setUseDefault('false');
$overrides = array("method"=> "popup","minutes" => "15");
$rem->setOverrides($overrides);
$event->setReminders($rem);
The event I am sending to the API contains the following data:
[reminders] => Google_EventReminders Object
(
[__overridesType:protected] => Google_EventReminder
[__overridesDataType:protected] => array
[overrides] => Array
(
[method] => popup
[minutes] => 15
)
[useDefault] => false
)
But the event itself does not appear in my calendar with a reminder.
Any pointers on what I'm doing wrong v.gratefully received. Thank you, Tony
You have to pass an array of reminders in the setReminders method, as in this example:
<?php
$reminder = new Google_EventReminders();
$reminder->setUseDefault(false);
$overrides = array("method"=> "popup","minutes" => "15");
$reminder->setOverrides(array($overrides));
$event->setReminders($reminder);
?>
In Google_EventReminders class, the method setOverrides only accepts an array of reminders to validate these settings (by the method assertIsArray), as shown below:
<?php
public function setOverrides(/* array(Google_EventReminder) */ $overrides) {
$this->assertIsArray($overrides, 'Google_EventReminder', __METHOD__);
$this->overrides = $overrides;
}
?>