posting data into multiple queue aws services - php

I working with Queue Component for Yii2 from reference https://libraries.io/github/cybercog/yii2-queue
I wants to know that how can i post data into 2-3 different queue url for different feature
for that i have to configure 2-3 user here in below configuration code plsease let me know how can i provide multiple url in configuration
'components' => [
'queue' => [
'class' => 'UrbanIndo\Yii2\Queue\SqsQueue',
'module' => 'task',
'url' => 'https://sqs.ap-southeast-1.amazonaws.com/123456789012/queue',
'config' => [
'key' => 'AKIA1234567890123456',
'secret' => '1234567890123456789012345678901234567890',
'region' => 'ap-southeast-1',
],
]]
or how can i set url while posting data into queue
Yii::$app->queue->post(new Job(['route' => ['sync' => 'emailSync'], 'data' => $options]));

Related

I'm trying to develop code in Laravel to copy a work item to another PBI, using the Azure DevOps API with PHP and Laravel

I'm trying to make a copy of work items (Tasks, etc.) from one location to another in Azure DevOps, using PHP and Laravel. I was able to send data in JSON format to the Azure API and create a task (according to the example posted). I can't make a copy. Can you help me?
Route::get('/add_work_item', function () {
$response = Http::withBasicAuth('{key}', '{PAT}')
->withHeaders([
'Content-Type' => 'application/json-patch+json'
])
->post('https://dev.azure.com/{Organisation}/{Project}/_apis/wit/workitems/$Task?api-version=5.1', [
[
'op' => 'add',
'path' => '/fields/System.Title',
'from' => null,
'value' => 'New Task'
],
[
'op' => 'add',
'path' => '/fields/System.AreaPath', 'from' => null, 'value' => '{Project}'
]
]);
return dd(json_decode($response->getBody()));
});

Registering custom\additional routes for a laravel websocket server?

So I'm using beyondcode/laravel-websockets to setup a WS server and I want to work with multiple apps so I did this in config\websockets.php:
'apps' => [
[
'id' => env('A_APP_ID'),
'name' => env('A_APP_NAME'),
'key' => env('A_APP_KEY'),
'secret' => env('A_APP_SECRET'),
'path' => env('A_APP_PATH'),
'capacity' => null,
'enable_client_messages' => false,
'enable_statistics' => true,
],
[
'id' => env('B_APP_ID'),
'name' => env('B_APP_NAME'),
'key' => env('B_APP_KEY'),
'secret' => env('B_APP_SECRET'),
'path' => env('B_APP_PATH'),
'capacity' => null,
'enable_client_messages' => false,
'enable_statistics' => true,
],
],
However, I want to implement custom handlers for each app and I've been trying this, routes\web.php:
WebSocketsRouter::webSocket('app/{appKey}/bapp', \App\WebSockets\BAppWebSocketHandler::class);
//Also tried this..
WebSocketsRouter::webSocket('app/{appKey}', \App\WebSockets\AAppWebSocketHandler::class);
//and created `AAppWebSocketHandler` which does nothing but calling parent (WebSocketHandler) methods
Problem is it's always using one handler for all apps despite the difference in routes.
Any ideas?
Thanks!
You don't have to define routes while defining multiple apps in the config. Instead configure Echo to work with separate app key and secret. If you want to use custom handler with own logic, then remove them from configs. Also note that, you won't get any channel or pusher client library support. You will have to implement your own authentication as well.

Struggling with s3 multipart upload guzzle for Eventbrite

I'm trying to upload to s3 based on the documentation in Eventbrite but I'm getting nowhere. I think it's down to the structure of my request but I've tried multiple different things and nothing is really working and I get a 'Bucket POST must contain a field named 'key' error.
The instructions are here, so it provides you with a presigned POST object, but I can't figure out how to then provide those details in Guzzle
https://www.eventbrite.com/developer/v3/resources/uploads/
I would use the s3client but I don't think it's suitable, as I do not have the region name.
So this is the array back from EB, as given in the documentation
$postFields = [
'key' => $post_args['key'],
'AWSAccessKeyId' => $post_args['AWSAccessKeyId'],
'bucket' => $post_args['bucket'],
'acl' => $post_args['acl'],
'signature' => $post_args['signature'],
'policy' => $post_args['policy'],
];
and I've tried various structures:
$args = [
'query' => $postFields,
'multipart' => [
[
'name' => $instructions_response['body']['file_parameter_name'],
'Content-type' => 'multipart/form-data',
'contents' => $image,
]
],
]
Or
$args = [
'multipart' => [
[
'key' => $post_args['key'],
'AWSAccessKeyId' => $post_args['AWSAccessKeyId'],
'bucket' => $post_args['bucket'],
'acl' => $post_args['acl'],
'signature' => $post_args['signature'],
'policy' => $post_args['policy'],
'name' => $instructions_response['body']['file_parameter_name'],
'Content-type' => 'multipart/form-data',
'contents' => $image,
]
],
];
Or
$args = [
'key' => $post_args['key'],
'AWSAccessKeyId' => $post_args['AWSAccessKeyId'],
'bucket' => $post_args['bucket'],
'acl' => $post_args['acl'],
'signature' => $post_args['signature'],
'policy' => $post_args['policy'],
'multipart' => [
[
'name' => $instructions_response['body']['file_parameter_name'],
'Content-type' => 'multipart/form-data',
'contents' => $image,
]
],
];
(Plus a bunch of more spurious ones that I can't remember anymore)
Anyway, I'm stuck. I just can't think how this POST data is meant to be structured for it to post to S3. I've gone down the rabbit hole with Xdebug and it's still not clear what is even going on when it makes the request tbh
Request called like so
$upload_response = $this->client->request('POST', $upload_url, $args);
UPDATE: It was pointed out to me that whilst 'key' is lowercase in the error message and what comes back from aws, it's capitalised in the documentation. I changed it to 'Key' and now I get 'Conflicting query string parameters: acl, policy'

EAuth Extension Yii2, Class nodge\eauth\EAuth does not exist

I am trying to use EAuth extension in Yii2 advanced application. I installed it through composer and it installed it under vendor directory and configured as mentioned here (did the config in common/config/main). So, following is the directory structure for that:
root
vendor
nodege
lightopenid
provider
*files go here*
yii2-eauth
src
*files go here*
EAuth.php is under src folder. In controller I have done this in use:
use nodge\eauth\EAuth;
and when I do this:
$eauth = Yii::$app->get('eauth')->getIdentity($serviceName);
I get the following error:
Class nodge\eauth\EAuth does not exist
What am I doing wrong? Any help?
Update:
This is my config:
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
'eauth' => [
'class' => 'nodge\eauth\EAuth',
'popup' => true, // Use the popup window instead of redirecting.
'cache' => false, // Cache component name or false to disable cache. Defaults to 'cache' on production environments.
'cacheExpire' => 0, // Cache lifetime. Defaults to 0 - means unlimited.
'httpClient' => [
// uncomment this to use streams in safe_mode
//'useStreamsFallback' => true,
],
'services' => [// You can change the providers and their classes.
'google' => [
// register your app here: https://code.google.com/apis/console/
'class' => 'nodge\eauth\services\GoogleOAuth2Service',
'clientId' => '...',
'clientSecret' => '...',
'title' => 'Google',
],
'facebook' => [
// register your app here: https://developers.facebook.com/apps/
'class' => 'nodge\eauth\services\FacebookOAuth2Service',
'clientId' => '---',
'clientSecret' => '---',
],
'yahoo' => [
'class' => 'nodge\eauth\services\YahooOpenIDService',
//'realm' => '*.example.org', // your domain, can be with wildcard to authenticate on subdomains.
],
],
],
],

Elastic Beanstalk deploy a docker environment from the API

I am at my whits end trying to solve this problem. Our ultimate goal is to deploy a custom docker container of Mautic. I have no problem doing this from their website interface. I've solved all my config problems and it works great. But I need to do this automatically from an API. Customers are going to sign up for our service, and we want to deploy Mautic for them instantly (or as instant as AWS can work).
I'm new to elastic beanstalk and AWS. But what I understand is I need to create an environment and deploy my Dockerrun.aws.json file to it. But I cannot find anywhere in the API that I can specify a file to deploy or even an S3 bucket to use (like you can from the interface). I had hoped by saving a template and using that, it would work, but I just get an empty Docker instance with no container launched.
Here's an example of my PHP api call
$eb = new ElasticBeanstalkClient(array(
'version' => 'latest',
'region' => 'us-east-1',
'credentials' => array(
'key' => '...',
'secret' => '...'
)
));
$newEnvironment = $eb->createEnvironment(array(
'ApplicationName' => 'test',
'TemplateName' => 'foo2',
'EnvironmentName' => '...',
'EnvironmentTier' => array(
'Type' => 'Standard',
'Name' => 'WebServer'
),
'OptionSettings' => array(
[
'Namespace' => 'aws:autoscaling:launchconfiguration',
'OptionName' => 'EC2KeyName',
'Value' => '...'
],
[
'Namespace' => 'aws:rds:dbinstance',
'OptionName' => 'DBUser',
'Value' => '...'
],
[
'Namespace' => 'aws:rds:dbinstance',
'OptionName' => 'DBPassword',
'Value' => '...'
]
)
));
The template foo2 was saved from an environment that has a fully running Mautic docker container.
The problem is, this creates an environment and the RDS resource I need, but does not run my docker container.
Is what I want possible? Or do I have to find another avenue?
Thanks
Figured it out. What I was looking for was $eb->createApplicationVersion(...) which I can use to specify an S3 bucket with my Dockerrun.aws.json file. Documentation
Then I can specify that VersionLabel in my createEnvironment() call like so.
$newEnvironment = $eb->createEnvironment(array(
'ApplicationName' => 'test',
'TemplateName' => 'foo2',
// Right here
'VersionLabel` => 'fooVersion',
'EnvironmentName' => '...',
'EnvironmentTier' => array(
'Type' => 'Standard',
'Name' => 'WebServer'
),
'OptionSettings' => array(
[
'Namespace' => 'aws:autoscaling:launchconfiguration',
'OptionName' => 'EC2KeyName',
'Value' => '...'
],
[
'Namespace' => 'aws:rds:dbinstance',
'OptionName' => 'DBUser',
'Value' => '...'
],
[
'Namespace' => 'aws:rds:dbinstance',
'OptionName' => 'DBPassword',
'Value' => '...'
]
)
));
Or I can just create a version through the Dashboard. Documentation

Categories