I'm trying to implement Mailgun API serive for handle my emails, this is my code according to the documentation:
index.php
require 'vendor/autoload.php';
use Mailgun\Mailgun;
$mgClient = Mailgun::create("key-xxxxxxxxxxxxxxxxxxxxxxxxxxx");
$domain = "xxxxxxx.com";
$mgClient->sendMessage($domain,
array('from' => 'Dwight Schrute<dwight#xxxxxxx.com>',
'to' => 'Michael Scott <xxxx#xxxxx.com>',
'subject' => 'The Printer Caught Fire',
'text' => 'We have a problem.'));
var_dump($result);
composer.json
"require": {
"mailgun/mailgun-php": "^2.3",
"php-http/curl-client": "^1.7",
"guzzlehttp/psr7": "^1.4"
}
everything works fine but $result contains tons of data instead of simple return array with id and message "message was queued thank you". Another problem is when I simulate error to see what happen, unfortunately Mailgun make fatal error instead of connection exception which I can handle:
[30-Nov-2017 10:05:44 UTC] PHP Fatal error: Uncaught exception 'Mailgun\Connection\Exceptions\MissingRequiredParameters' with message 'The parameters passed to the API were invalid. Check your inputs! Free accounts are for test purposes only. Please upgrade or add the address to authorized recipients in Account Settings.' in /home/xxx/xxx/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php:254
Stack trace:
#0 /home/xxx/xxx/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php(110): Mailgun\Connection\RestClient->responseHandler(Object(GuzzleHttp\Psr7\Response))
#1 /home/xxx/xxx/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php(179): Mailgun\Connection\RestClient->send('POST', 'xxxxx.com...', Array, Array)
#2 /home/xxx/xxx/vendor/mailgun/mailgun-php/src/Mailgun/Mailgun.php(204): Mailgun\Connection\RestClient->post('xxxxx.com...', Array, Array)
#3 /home/xxx/xxx/vendor/mailgun/mailgun-php/src/Mailgun/Mailgun.php(135): Mailgun\Mailgun->post(' in /home/xxxxxx/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php on line 254
I'm using PHP 7 os linux no framework. What I'm doing wrong? Thanks for any advice.
This error occurs whenever utilizing either a sandbox domain or a free account without inviting users called Authorized Recipients. Free plans are intended for test usage and all custom domains require Authorized Recipients. With upgraded plans, custom domains no longer require Authorized Recipients.
Please take a look at the following Help Center article for more information about the Authorized Recipient process:
https://help.mailgun.com/hc/en-us/articles/217531258-Authorized-Recipients
For more information on upgrading, please review:
https://help.mailgun.com/hc/en-us/articles/203599840-How-do-I-upgrade-my-account-
Disclaimer I work at Mailgun
Related
I'm trying to connect to our cloud account, but I get the following error:
Fatal error: Uncaught Error: Class 'ActiveCollab\SDK\Authenticator\Cloud' not found in /www/htdocs/asdf/asdf.org/example-cloud.php:13 Stack trace: #0 {main} thrown in /www/htdocs/asf/asdf.org/example-cloud.php on line 13
require_once('https://app.activecollab.com/xxxxxx/autoload.php');
// Provide name of your company, name of the app that you are developing, your email address and password.
$authenticator = new \ActiveCollab\SDK\Authenticator\Cloud('xxx', 'My Awesome Application', 'vvv#ghf.de', '123qwe123*');
// Show all Active Collab 5 and up account that this user has access to.
print_r($authenticator->getAccounts());
// Show user details (first name, last name and avatar URL).
print_r($authenticator->getUser());
// Issue a token for account #123456789.
$token = $authenticator->issueToken('123456789');
// Did we get it?
if ($token instanceof \ActiveCollab\SDK\TokenInterface) {
print $token->getUrl() . "\n";
print $token->getToken() . "\n";
} else {
print "Invalid response\n";
die();
}
What did I wrong?
First line in your code example is not good. You should check the article on basic usage of Composer prior to continuing: https://getcomposer.org/doc/01-basic-usage.md
Once you have properly set up Composer in your development environment, required ActiveCollab SDK, and updated dependencies, your first line will most probably look like this:
require __DIR__ . '/vendor/autoload.php';
But you said:
Installation
If you choose to install this application with Composer instead of pulling down the git repository you will need to add a composer.json file to the location you would like to pull the repository down to featuring:
So I tried to pull down the repository s- or am I wrong ...
https://github.com/activecollab/activecollab-feather-sdk
I am trying to use describeDomains function of AWS CloudSearch. But I am getting the below error.
exception 'ReflectionException' with message 'Method Aws\CloudSearch \CloudSearchClient::describeDomains() does not exist
You've probably already figured this out by now, but I think you just need to fix the casing of the DescribeDomains() method (note the initial capital D).
See PHP SDK documentation:
https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-cloudsearch-2013-01-01.html#describedomains
I'm using Laravel 4.2 and want to get logs out as JSON. Laravel uses Monolog, so I've configured the JSON formatter like so:
$logHandler = new Monolog\Handler\StreamHandler(Config::get('app.logFile'), Monolog\Logger::DEBUG);
$logHandler->setFormatter(new Monolog\Formatter\JsonFormatter);
Log::getMonolog()->pushHandler($logHandler);
The problem is that stack traces are included as part of the message string, like so:
{
"message": "exception 'Exception' with message 'Socket operation failed: Host name lookup failure' in /var/www/vendor/clue/socket-raw/Socket/Raw/Socket.php:388\nStack trace:\n#0 /var/www/vendor/clue/socket-raw/So..."
}
Can someone point me in the right direction to make the stack trace its own separate array in the json?
Long overdue update:
The primary problem is that Laravel, and lots of code following its example, tries to log the exception by itself, e.g., Log::error($e). This is the wrong way to log an exception with Monolog. That first parameter is supposed to be a simple message string. In processing it, Monolog\Logger::addRecord() explicitly casts the message to a string:
$record = array(
'message' => (string) $message,
//...
);
If $message is actually an exception, you get the whole stack trace as a string. Unfortunately, this is what Laravel's default exception handler does.
The correct way to get a stack trace as an array is to pass the exception in as context so that it's available non-stringified to the formatter. For instance:
Log::error($e->getMessage(), ['exception' => $e]);
Something equivalent is what you need to put in your custom exception handler for Laravel, and then you can use a proper JSON formatter and get what you except.
Trying to implement the Twilio Client Conference Call Monitor as described here:
https://www.twilio.com/docs/howto/twilio-client-browser-conference-call-monitor
It "sees" ongoing conferences and has output like this:
Found 0 conference(s)
Found 1 conference(s)
etc.
However, it doesn't list the ongoing conferences as desired. No further output is given.
In the ssl_error_log, I found this, which is interesting:
PHP Fatal error: Uncaught exception 'Exception' with message 'Objects
returned by Services_Twilio_Page::getIterator() must be traversable or
implement interface Iterator' in /mypath/call_monitor.php:74\nStack
trace:\n#0 /mypath/call_monitor.php(74): unknown()\n#1 {main}\n
thrown in /mypath/call_monitor.php on line 74
I don't find any results here or on Google for this message, so I'm thinking it's particular to my setup.
I'm using Linux / Apache / PHP Version 5.2.17.
The support team at Twilio advised the following:
...it looks like there's a bug in the example code. Can you change
this:
$conferences = $client->account->conferences->getPage(0, 50, array('Status' => 'in-progress'));
to:
$conferences = $client->account->conferences->getIterator(0, 50, array('Status' => 'in-progress'));
i.e. change "getPage" to "getIterator" ?
This corrected the error I reported, but introduced other issues not within the scope of this question.
I have a project with simple authentication by mysql database with username and password. I have simple form for authentication with 3 fields: pass, user and yubico key. I want to have two variants of authentication: by login+pass and by only yubico key. Now I created custom Authentication Provider by tutorial in this topic.
As a result, it does not work. I get this error log:
exception
'Symfony\Component\Security\Core\Exception\BadCredentialsException'
with message 'Bad credentials' in
E:\Dropbox\hmciAdmin\vendor\symfony\symfony\src\Symfony\Component\Security\Core\Authentication\Provider\UserAuthenticationProvider.php:70
Stack trace: #0 E:\Dropbox\hmciAdmin\app\cache\dev\classes.php(183):
session_start() #1
E:\Dropbox\hmciAdmin\app\cache\dev\classes.php(277):
Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start()
My code here:
https://dl.dropbox.com/u/30086473/Authentication/Firewall/YubicoListener.php
https://dl.dropbox.com/u/30086473/Authentication/Provider/YubicoProvider.php
https://dl.dropbox.com/u/30086473/Authentication/Token/YubicoToken.php
https://dl.dropbox.com/u/30086473/Authentication/Token/config/services.yml
https://dl.dropbox.com/u/30086473/Authentication/Token/config/config/security.yml
UPDATE:
https://dl.dropbox.com/u/30086473/YubicoFactory.php - here Factory
UPDATE 2:
I solve this problem. The problem was that I used the same html form for both types of authorizations, but it was necessary to send yubico key to url of the page that is being protected. Now all work. Thanks all for help.