Symfony\Component\Debug\Exception\FatalThrowableError.
Argument 1 passed to App\Http\Controllers\API\BotManController::App\Http\Controllers\API{closure}() must be an instance of BotMan\BotMan, instance of BotMan\BotMan\BotMan given.
I tried to implement NLP APIAI in Botman with the help of documentation provided
but I couldn't find the issue. what I have tried is shown in my code below.
use BotMan\BotMan\Middleware\ApiAi;
public function handle(Request $request){
$config = ['web'=>['matchingData'=>['driver'=>'web']]];
DriverManager::loadDriver(\BotMan\Drivers\Web\WebDriver::class);
$doctrineCacheDriver = new \Doctrine\Common\Cache\PhpFileCache('cache');
$botman = BotManFactory::create($config, new DoctrineCache($doctrineCacheDriver));
$dialogflow = ApiAi::create('dialog_flow_client_token')->listenForAction();
$botman->middleware->received($dialogflow);
// Apply matching middleware per hears command
$botman->hears('intent-action-name', function (BotMan $bot){$extras = $bot->getMessage()->getExtras();
$apiReply = $extras['apiReply'];$apiAction = $extras['apiAction'];$apiIntent = $extras['apiIntent'];
})->middleware($dialogflow);
$botman->listen();
}
Make an explicit call for BotManĀ in the function closure dependency injection to avoid confusion with current namespace
$botman->hears('intent-action-name', function (\BotMan\BotMan $bot) {
$extras = $bot->getMessage()->getExtras();
$apiReply = $extras['apiReply'];
$apiAction = $extras['apiAction'];
$apiIntent = $extras['apiIntent'];
})->middleware($dialogflow);
Hope this helps
using \BotMan\BotMan worked instead of using Botman importing use BotMan\BotMan; .Thanks #sally 3301 it worked
Related
I'm having issues with this... I'm trying to install "downGrade - Single Vendor Digital Products Marketplace
"
https://codecanyon.net/item/downgrade-single-vendor-digital-products-marketplace/28803672?gclid=Cj0KCQjw2MWVBhCQARIsAIjbwoOi08ajt47xsPKUsGZ7V7mr7KD5W_CwaQS-BfF1tbP1OE0-LpNdR6caAmCbEALw_wcB
I'm getting this error code and I'd like to receive your help, thank you.
$admin = Members::adminData();
View::share('admin', $admin);
$allsettings = Settings::allSettings();
View::share('allsettings', $allsettings);
$allcountry = Settings::allCountry();
View::share('allcountry', $allcountry);
$country['country'] = Settings::allCountry();
View::share('country', $country);
$demo_mode = 'off'; // on
View::share('demo_mode', $demo_mode);
$main_menu['category'] = Category::mainmenuCategoryData($allsettings->menu_display_categories,$allsettings->menu_categories_order);
View::share('main_menu', $main_menu);
$footer_menu['category'] = Category::mainmenuCategoryData($allsettings->footer_menu_display_categories,$allsettings->footer_menu_categories_order);
View::share('footer_menu', $footer_menu);
$footerpages['pages'] = Pages::footermenuData();
View::share('footerpages', $footerpages);
$languages['view'] = Languages::allLanguage();
View::share('languages', $languages);
if(!empty(Cookie::get('translate')))
{
The reason why you getting the error is that the $allsetting is null.
$main_menu['category'] = Category::mainmenuCategoryData($allsettings->menu_display_categories,$allsettings->menu_categories_order);
The $allsettings gets the value from the setting table from the database where you can easily see the value menu_display_categories is nulled.
//Nulled here ---> $allsettings->menu_display_categories
Solution: Enter the values in all columns inside the setting table.
I am trying to store heavy image through the laravel queue as follows because i dont want my user to wait until file gets stored:
This code is in controller
if($request->hasfile('featuringPhoto'))
{
$prefixFilename = date("Y-m-d-H-i-s");
$coverFilename = $prefixFilename.$request->featuringPhoto->getClientOriginalName();
ProceessFiles::dispatch($request->featuringPhoto->getRealPath(),$coverFilename);
}
else
{
$coverFilename4 = NULL;
}
Below code is in job
protected $files, $filename;
public function __construct($files,$filename)
{
$this->files= $files;
$this->filename = $filename;
}
public function handle()
{
if($this->files){
$coverFilename = $prefixFilename.$this->filename;
$img = file_get_contents($this->files);
$img->storeAs('images/photosUploadedByUser', $coverFilename, 'public');
}
}
It Gives me an error saying Call to a member function storeAs() on string
I tried this solution from stack but didnt work
Any suggestion will be appreciated.Thank you.
I think it is wrong to assume you are gonna save a lot time by executing the save operation in a queue, also because you are already fetching it from the web server. Queues will with scaling often be moved to worker servers and with this approach this will not work.
In the spirit of the question, stackoverflow and to explain to you what is not working. file_get_contents() returns the content of the file as a string. So to fix your problem, you should just store the results of that. You obviously can not call methods on strings.
$coverFilename = $prefixFilename.$this->filename;
$img = file_get_contents($this->files);
Storage::put('images/photosUploadedByUser/' . $coverFilename, $img);
I'm getting an error using Laravel PayPal billing agreement. I received HTTP response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/billing-agreements/. I'm
getting this error once I try to complete the agreement process.
$id = my_created_plan_id
protected function agreement($id)
{
$agreement = new Agreement();
$agreement->setName('Base Agreement')->setDescription('Basic Agreement')
// ->setStartDate(date("Y-m-d").'T9:45:04Z'); ->setStartDate('2021-07-05T9:45:04Z');
$agreement->setPlan($this->Plan($id));
$agreement->setPayer($this->payer());
$agreement->setShippingAddress($this->shippingAddress());
$agreement = $agreement->create($this->apiContext);
return $agreement->getApprovalLink();
}
protected function Plan($id)
{
$plan = new Plan();
$plan->setId($id);
return $plan;
}
protected function payer()
{
$payer = new Payer();
$payer->setPaymentMethod('paypal');
return $payer;
}
protected function shippingAddress()
{
$shippingAddress = new ShippingAddress();
$shippingAddress->setLine1('111 First Street')
->setCity('Saratoga')
->setState('CA')
->setPostalCode('95070')
->setCountryCode('US');
return $shippingAddress;
}
You are using a deprecated SDK that does not support the current version of PayPal Subscriptions, for which there is no SDK.
Change your integration to not use that old SDK. The new Subscribe button itself is JavaScript. Use direct HTTPS calls with curl or similar when you need to call an API to create Products and Plans or administer Subscriptions.
(You can also do so in your account's web interface, rather than via API)
Sandbox: https://www.sandbox.paypal.com/billing/
Live: https://www.paypal.com/billing/
protected function agreement($id)
{
$agreement = new Agreement();
$agreement->setName('Base Agreement')->setDescription('Basic Agreement')
// ->setStartDate(date("Y-m-d").'T9:45:04Z'); ->setStartDate('2021-07-05T9:45:04Z');
//Replace above line with below line
//->setStartDate(gmdate("Y-m-d\TH:i:s\Z", time()+60));
$agreement->setPlan($this->Plan($id));
$agreement->setPayer($this->payer());
$agreement->setShippingAddress($this->shippingAddress());
$agreement = $agreement->create($this->apiContext);
return $agreement->getApprovalLink();
}
You cannot comment on the start date of the agreement.
you must provide the start date of agreement and the error occurred due to this issue.
Script code
class Deposit extends MY_Controller
{
public function coinPaymentCron()
{
$this->load->model('user_model','apimodel');
$apikeys = $this->apimodel->getApiKey();
foreach ($apikeys as $keysapi) {
# code...
$publickey = $keysapi->public_key;
$privatekey = $keysapi->private_key;
}
$cps = new CoinPaymentsAPI();
$cps->Setup($privatekey, $publickey);
$getTxIds = $this->apimodel->gettxids();
foreach ($getTxIds as $txid) {
# code...
$tx_id = $txid->txn_id;
echo $tx_id;
$txinfo = $cps->gettxinfo($tx_id);
if ($txinfo['error'] == 'ok') {
# code...
$statusText = $txinfo['result']['status_text'];
$amountReceived = $txinfo['result']['receivedf'];
$statusPayment = $txinfo['result']['status'];
$this->apimodel->updateStatus($tx_id, $statusText);
}
}
}
}
The code command i am using for running cron job is
/usr/local/bin/php /home/name/public_html/index.php deposit coinPaymentCron
I have also tried many methods like using wget and curl but unfortunately none work for me.
Also checked the script using url and the script is running fine and updating the database but the cron job is not running.
Some other cron jobs are running using this method
/usr/local/bin/php /home/name/public_html/index.php
Can anyone please help regarding this issue or let me know what I am doing wrong?
As I know there are a lot of ways to call function of CodeIgniter e.g.
This solution working for me
php /full-path-to-cron-file/cron.php /deposit/coinPaymentCron
also, you can try with this:
wget example.com/index.php/deposit/coinPaymentCron
Or
*/15 * * * * /opt/php55/bin/php /home/username/public_html/myapp/index.php deposit coinPaymentCron
But you read this tutorial: http://www.asim.pk/2009/05/14/creating-and-installing-crontabs-using-codeigniter/ and follow instruction. It will be helpful for you.
This listener sends me reports on all kinds of exceptions that occur on the website. Sometimes I get reports of images that have been deleted but are still consulted by search engines and others.
I want to do, instead of displaying an error message " 404 Not Found " return the correct image. To do this I created a database table that stores the old links and new links of the images that have been deleted, moved or changed its name.
then, this listener find in db the links to fallen and gets the new links of images . The goal is to return the image as http-response with header content-type as image.
My code is:
class ExceptionListener
{
private $service_container;
private $router;
function __construct(Container $service_container, $router){
$this->service_container = $service_container;
$this->router = $router;
}
public function onKernelException(GetResponseForExceptionEvent $event){
$exception = $event->getException();
$request = $this->service_container->get('request');
...
$document_root = $request->server->get('DOCUMENT_ROOT');
$filename = realpath($document_root . '/'. '/path/to/new_image.jpg');
$response = new \Symfony\Component\HttpFoundation\Response();
$response->headers->set('Content-type', 'image/jpeg');
$response->headers->set('Content-Disposition', 'inline; filename="' . basename($filename) . '";');
$response->headers->set('Content-length', filesize($filename));
$response->sendHeaders();
$response->setContent(file_get_contents($filename));
return $response;
...
}
}
The following error occurs:
In the browser you can see a small box , it is as if trying to show the image but the image source could not be obtained . But if the same code is testing on controller , its working properly and the image is displayed .
What can I do to return image from a listener ? thanks
There's few things wrong about the code snippet from your question.
Firstly, you should never use the request service. It's deprecated since Symfony 2.4 and was removed in Symfony 3.0. Use the request stack (request_stack) instead.
Secondly, do not send the response yourself, but let the framework do it. Symfony events system is designed for flexibility (see the docs). In your case it's enough to set the response on the event object.
Finally, you don't need the service container to access the request at all, as it's available on the event.
Moreover, instead of the standard Response class you can use the BinaryFileResponse. It's purpose is to serve files (have a look at the docs).
You can greatly simplify your listener:
use Symfony\Component\HttpFoundation\BinaryFileResponse;
class ExceptionListener
{
private $router;
function __construct($router)
{
$this->router = $router;
}
public function onKernelException(GetResponseForExceptionEvent $event)
{
$exception = $event->getException();
// request is avialable on the event
$request = $event->getRequest();
// ...
$file = 'path/to/file.txt';
$response = new BinaryFileResponse($file);
// ... set response parameters ...
// finally, set the response on your event
$event->setResponse($response);
}
}