Trouble adding intent to bot - php

When trying to add an intent to a bot, I'm getting the following:
{"message":"The resource 'SomeBotThatDefinitelyExists' referenced in resource 'TestBot' was not found. Choose another resource."}
I'm calling the putBot method, and passing the intents below:
`'intents' => [
[
'intentName' => 'SomeBotThatDefinitelyExists',
'intentVersion' => '1',
],
[
'intentName' => 'TestingTheBot',
'intentVersion' => '1'
]
]`
I am absolutely positive that I've successfully created the offending intent. I can see it in the AWS panel, and via the api. The only difference that I can see between the two intents is that the second intent, 'TestingTheBot' has been included in a previous version of the bot. I am able to add it via the api without issue, but, again, trying to add SomeBotThatDefinitelyExists returns the error above.

For anyone with the same issue, I discovered that intents created with putIntent don't have a version. After creating an intent, you must call createIntentVersion. You can then obtain the latest version from the intent returned by the API. That should be the version you use to set the intentVersion property when adding an intent to a bot.

Related

How can I query AWS Batch for jobs matching multiple jobStatus values in AWS PHP SDK Version 3?

I am currently working on a PHP project using the AWS PHP SDK. I have a data import process that utilizes AWS batch. The PHP application needs to be able to check AWS for jobs that are not complete, prior to letting the user start a new job.
I am currently using the listJobs() call on the BacthClint like so, following an example given by the documentation:
<?php
$client = new Aws\Batch\BatchClient([
...
]);
$jobs = $client->listJobs([
'jobQueue' => '...',
'jobStatus' => 'RUNNING',
]);
However, I would like to get jobs matching the statuses of SUBMITTED, PENDING, RUNNABLE and STARTING as well as RUNNING.
The docs make it seem like I could submit the following value, as a pipe delinted list. But this syntax caused the request to fail:
<?php
$jobs = $client->listJobs([
'jobQueue' => '...',
'jobStatus' => 'SUBMITTED|PENDING|RUNNABLE|STARTING|RUNNING',
]);
Error:
Error executing request, Exception : Invalid job status SUBMITTED|PENDING|RUNNABLE|STARTING|RUNNING. Valid statuses are [SUBMITTED, PENDING, RUNNABLE, STARTING, RUNNING, SUCCEEDED, FAILED]
Is there some kind of way that I can submit multiple values under the 'jobStatus' input?
If not, is there some other way I can do this utilizing the AWS PHP SDK?
Note:
It looks like there is a 'filters' feature listed under the heading "Parameter Details" and "Parameter Syntax" secotion in the documentation example from before. This seems to suggest that something like this should work:
<?php
$jobs = $client->listJobs([
'jobQueue' => '...',
'filters' => [
'name' => 'jobStatus',
'values' => ['SUBMITTED', 'PENDING', 'RUNNABLE', 'STARTING', 'RUNNING']
]
]);
"You can filter the results by job status with the jobStatus parameter. If you don't specify a status, only RUNNING jobs are returned."
"The job status used to filter jobs in the specified queue. If the filters parameter is specified, the jobStatus parameter is ignored and jobs with any status are returned. If you don't specify a status, only RUNNING jobs are returned."
However this seems to return blank result sets.

Laravel Cashier sends no POST request body on heroku

Ive been running into issues with Laravel Cashier when i deployed my app to heroku.
One my local environment everything is fine but on my staging server , no POST request body is ever sent to stripe.
I tried swapping api keys as i thought maybe the api version on stripe differs between the two but that doesn't work (see screenshots below)
Things i know are correct
API creds , they wont show up on stripe logs if it wasent
Composer version matches both environments (Laravel Cashier 10.5.2, Laravel 5.8.36, Stripe-php 17.7.0)
I cant seem to find anything that logs out going api requests. Ive even tried manually calling the stripe functions as low as i can get in the stack still no POST body.
Im sure some one else has ran into this. Google search on laravel cashier ALWAYS sends me back to the laravel website, like WTF.
this is my stripe method on my User model. All other code is from Cashier
public function activateSubscription() {
if ($this->hasStripeId() &&
$this->has_default_payment_method &&
$this->has_active_subscription) {
return;
}
try {
$this->newSubscription(env('STRIPE_SUBSCRIPTION_NAME'), env('STRIPE_PLAN_ID'))
->create(null, [
'name' => $this->fullname,
'email' => $this->email,
]);
$this->notify(new UserRegistered());
} catch (\Stripe\Exception\InvalidRequestException $e) {
Log::debug('Invalid Request', [
'body' => $e->getHttpBody(),
'headers' => $e->getHttpHeaders(),
'json' => $e->getJsonBody(),
'error_code' => $e->getStripeCode(),
]);
}
}
Edit
Ive removed some personal details from the POST request body
I figured it out , i had a \n at the end of my stripe secret api key on heroku environment variables.
For some reason that caused all requests to stripe to strip the POST body.
Removed that, ran a php artisan config:clear and it worked

Laravel dispatch plain json on queue

I have 2 simple questions overall. Im currently looking into some event handling in Laravel and would like to use RabbitMQ as my event store. Therefor i installed this package to start with: https://github.com/php-enqueue/enqueue-dev
To get started i registered it and i am able to push messages on to RabbitMQ:
$job = (new Sendemail())->onQueue('email')->onConnection('interop');
dispatch($job);
The problem however is that Laravel pushes a certain format on the queue and i can't figure out how to change that. An example message would be:
{
"job":"Illuminate\\\\Queue\\\\CallQueuedHandler#call",
"data":{
"command":"O:29:\\"Acme\\Jobs\\FooJob\\":4:{s:11:\\"fooBar\\";s:7:\\"abc-123\\";s:5:\\"queue\\";N;s:5:\\"delay\\";N;s:6:\\"\\u0000*\\u0000job\\";N;}"
}
}
So the question is, how can i change this? The main reason on this is that the consumer side is not even a PHP application which also can not interpret the PHP serialized model. Therefor im looking for a way to push a plain JSON object instead.
From the other hand i would also like to understand how you could build a custom listener? For the listener the same thing happens. Laravel tries to read the method but when i push plain JSON this will never work. Isn't there a way to register a handler on a topic and do further handling of the payload of the message within the handler itself?
There is a simple way for your purpose:
First install this package for rabbit:
vladimir-yuldashev/laravel-queue-rabbitmq
and in controller:
Queue::connection('rabbitmq')->pushRaw('{you can generate a json format here}', 'queue_name');
you can generate a json and put in this command.
There's a laravel-queue library that works with the php-enqueue library you linked to make it compatible with Laravel's built in queue system that Florian mentioned.
By default, it will still use a serialized object, but I think that can be overridden. If you look in Queue.php, createObjectPayload() on line 130 in the core Laravel Framework, that's where the job is being serialized.
If you extend the Queue class in the laravel-queue library, you should be able to change createObjectPayload to look something like this:
protected function createObjectPayload($job, $queue)
{
$payload = $this->withCreatePayloadHooks($queue, [
'displayName' => $this->getDisplayName($job),
'job' => 'Illuminate\Queue\CallQueuedHandler#call',
'maxTries' => $job->tries ?? null,
'timeout' => $job->timeout ?? null,
'timeoutAt' => $this->getJobExpiration($job),
'data' => [
'commandName' => $job,
'command' => $job,
],
]);
return array_merge($payload, [
'data' => [
'commandName' => get_class($job),
'command' => json_encode(clone $job),
],
]);
}
That should JSON encode the job data instead of serializing it. You may even be able to remove the encoding altogether, as I think it's already JSON encoded somewhere up the chain.

PHP Sagepay iframe integration

I want to make my website payments via sagepay. The problem is I am not able to locate all the things in the PHPKit they provide. The version of the kit is 3.0 and I want to configure iframe integration but when I open the test method there is this piece of code
$view = new HelperView('server/low_profile');
$view->setData(array(
'env' => $this->sagepayConfig->getEnv(),
'vendorName' => $this->sagepayConfig->getVendorName(),
'integrationType' => $this->integrationType,
'request' => HelperCommon::getStore('txData'),
));
$view->render();
I want to locate those keys 'env', 'vendorName', 'integrationType', 'requests' and see how to put them to use in my system. I see this syntax in a lo of places
public function setSagepayConfig(SagepaySettings $sagepayConfig)
{
$this->sagepayConfig = $sagepayConfig;
}
But I don't know what SagepaySettings means and how to trace it. Can you tell me where can I find SagepaySettings, or what does this mean. Is it a class or method or attribute, because I cannot find it in all the files as any of those.
It's a class in \lib\classes\settings.php

Taobao API - isv.permission-api-package-empty

I'm new with Taobao API and I'm not Chinese. I need to obtain category list and items from Taobao.com.
I'm using Yii and this extension: http://www.yiiframework.com/extension/topsdk4yii/
I have Api key and Api Secret, I'm trying to make a query and a receive this error:
object(stdClass)[16]
public 'code' => int 11
public 'msg' => string 'Insufficient isv permissions' (length=28)
public 'sub_code' => string 'isv.permission-api-package-empty' (length=32)
I make query in this way ( in SiteController.php -> function actionIndex() ):
Yii::import('application.extensions.taobao.request.*');
$request = new ShopGetRequest();
$request->setNick('my_username_from_taobao');
$request->setFields('sid,cid,title,nick,desc,bulletin,pic_path,created,modified');
$shop = Yii::app()->top->execute($request);
var_dump($shop);
I found some explanation here http://open.taobao.com/support/question_detail.htm?id=496 but I can't find how to fix this.
Please help me.
Thanks in advance.
You can't fix it from your application
you have to tell to the Api owner to white-list your server ip address if not done your application will not be able to make requests to taobao api.
The error means your application has not applied for the required permissions. You can do this from the application menu (providing an explanation of the application plus reason for applying in Chinese), after which they will handle your application within 3 working days.

Categories