Uncaught Error: Class 'Client' not found in chat-api - php

Im not good usig php, i just installed composer and just created this composer.json in my new project directory:
{
"require": {
"chatapi/whatsapp": "dev-master"
}
}
then I created a file named "whatsapp-sender.php" with the following:
<?php
require "vendor/autoload.php";
$client = Client::getInstance([
'url' => '<ULR>',
'token' => '<TOKEN>'
]);
$client->sendMessage([
'phone' => '<PHONE_NUMBER>',
'body' => 'Hi there!'
]);
?>
but when i try to run it to send a message this error appeared:
F:\BotGenes\PHP\Chat-api>php whatsapp-sender.php PHP Fatal error:
Uncaught Error: Class 'Client' not found in
F:\BotGenes\PHP\Chat-api\whatsapp-sender.php:5 Stack trace:
0 {main} thrown in F:\BotGenes\PHP\Chat-api\whatsapp-sender.php on line 5
Fatal error: Uncaught Error: Class 'Client' not found in
F:\BotGenes\PHP\Chat-api\whatsapp-sender.php:5 Stack trace:
0 {main} thrown in F:\BotGenes\PHP\Chat-api\whatsapp-sender.php on line 5
Can somebody help me please?

Related

Having issue with adding product through PHP code in STRIPE Payment

**I am trying to add payment in my stripe account through api but i am getting this error **
Notice: Undefined property: Stripe\Service\CoreServiceFactory::$price in C:\xampp\htdocs\sentemail\stripe-php-7.88.0\lib\Service\AbstractServiceFactory.php on line 55 Fatal error: Uncaught Error: Call to a member function create() on null in C:\xampp\htdocs\sentemail\price.php:10 Stack trace: #0 {main} thrown in C:\xampp\htdocs\sentemail\price.php on line 10
AND THIS IS MY CODE PLEASE HELP ME TO RESOLVE THIS ISSUE
<?php ini_set("display_errors", 1); require 'stripe-php-7.88.0/init.php';
$stripe = new \Stripe\StripeClient( 'pk_test_mykey' );
$stripe->price->create([ "id" => "pi_1Dor642eZvKYlo2C96OeaLE3", "object"=> "payment_intent", 'price' => 'price_1JCMCeLGVxlfB4ARCzBODYPv', 'currency' => 'usd', 'payment_method_types' => ['payment'],
'name' =>"Hamza",
]);
According to the Stripe documentation (section "prices") you should use
$stripe->prices->create([...]); not $stripe->price->create([...]);.
https://stripe.com/docs/api/prices/create?lang=php

PHP SOAP Error Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: can't import schema from

I am trying to create a SOAP Client from a WSDL file, but I always get this error bellow.
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: can't import schema from 'https://..../CreateQuote?xsd=createQuote_datamodel.xsd', namespace must not match the enclosing schema 'targetNamespace' in C:\xampp\htdocs\kfz\test.php:23 Stack trace: #0 C:\xampp\htdocs\kfz\test.php(23): SoapClient->SoapClient('https://testws1...', Array) #1 {main} thrown in C:\xampp\htdocs\kfz\test.php on line 23
Here is my code:
$xml = file_get_contents("out.xml");
$soapOptions = array(
'soap_version' => SOAP_1_1,
'exceptions' => true,
'trace' => 1,
'wsdl_local_copy' => false,
'keep_alive' => true,
);
$soapClient = new SoapClient($wsdlUrl, $soapOptions);
$soapClient->CreateQuote($xml);
Can anyone help me please?
I also tried it with non WSDL mode but it's still not working

YII2 error - The "id" configuration for the Application is required

I'm trying to start with YII2 (I should say that quite difficult after ASP.NET MVC) and got this error, but can't get what's wrong - id property has been set.
<?php
return [
'id' => 'crmapp',
'basePath' => realpath(__DIR__ . '/../'),
'components' => [
'request' => [
'cookieValidationKey' => 'somekey'
],
'urlManager'=>[
'enablePrettyUrl'=>true,
'showScriptName'=>false
]
],
'db'=> [
require(__DIR__.'/db.php'),
]];
Here is full error text:
Fatal error: Uncaught exception 'yii\base\InvalidConfigException' with message 'The "id" configuration for the Application is required.' in C:\xampp\htdocs\crmapp\vendor\yiisoft\yii2\base\Application.php:220 Stack trace: #0 C:\xampp\htdocs\crmapp\vendor\yiisoft\yii2\base\Application.php(202): yii\base\Application->preInit('C:\\xampp\\htdocs...') #1 C:\xampp\htdocs\crmapp\web\index.php(10): yii\base\Application->__construct('C:\\xampp\\htdocs...') #2 {main} thrown in C:\xampp\htdocs\crmapp\vendor\yiisoft\yii2\base\Application.php on line 220
Here is web/index.php
<?php
require(__DIR__.'/../vendor/yiisoft/yii2/Yii.php');
$config = (__DIR__.'/../config/web.php');
(new yii\web\Application($config))->run();
Here's your problem:
$config = (__DIR__.'/../config/web.php');
$config contains the path to web.php, not its contents. It should be:
$config = require(__DIR__ . '/../config/web.php');

Mailgun : Fatal error: Uncaught exception 'Guzzle\Common\Exception\InvalidArgumentException' with message 'Unable to open

I have used the following code and I have placed these files in the same directory as of the script I am running to send the mail. The exception continues to be thrown even when I try to give an online link.
I am trying this piece of PHP code in my local host which you can figure out from the error below
# Include the Autoloader (see "Libraries" for install instructions)
require 'mail/vendor/autoload.php';
use Mailgun\Mailgun;
# Instantiate the client.
$mgClient = new Mailgun('key-secret');
$domain = "mydomain";
$result = $mgClient->sendMessage($domain, array(
'from' => 'email',
'to' => 'email',
'bcc' => 'email',
'subject' => "Sending Attachment 2",
'text' => "Sending Attachment",
'html' => "Sending Attachment",
'attachment-1'=> 'test.xml'
), array("attachment" => array(
array('filePath' => '#/file.txt',
'remoteName' => 'file.txt'),
array('filePath' => '#/test.txt',
'remoteName' => 'test.txt'))));
Fatal error: Uncaught exception
'Guzzle\Common\Exception\InvalidArgumentException' with message
'Unable to open /file.txt for reading' in
C:\xampp\htdocs\zendeskapis\mail\vendor\guzzle\guzzle\src\Guzzle\Http\Message\PostFile.php:53
Stack trace: #0
C:\xampp\htdocs\zendeskapis\mail\vendor\guzzle\guzzle\src\Guzzle\Http\Message\PostFile.php(28):
Guzzle\Http\Message\PostFile->setFilename('#/file.txt') #1
C:\xampp\htdocs\zendeskapis\mail\vendor\guzzle\guzzle\src\Guzzle\Http\Message\EntityEnclosingRequest.php(199):
Guzzle\Http\Message\PostFile->__construct('attachment', '#/file.txt',
NULL, 'file.txt') #2
C:\xampp\htdocs\zendeskapis\mail\vendor\mailgun\mailgun-php\src\Mailgun\Connection\RestClient.php(52):
Guzzle\Http\Message\EntityEnclosingRequest->addPostFile('attachment',
'#/file.txt', NULL, 'file.txt') #3
C:\xampp\htdocs\zendeskapis\mail\vendor\mailgun\mailgun-php\src\Mailgun\Mailgun.php(80):
Mailgun\Connection\RestClient->post('hotelpalmshore....', Array,
Array) #4 C:\xampp\htdocs\zendeskapis\mail\vendor\mailgun\mailgun-php\
in
C:\xampp\htdocs\zendeskapis\mail\vendor\guzzle\guzzle\src\Guzzle\Http\Message\PostFile.php
on line 53
As the exception state it, your file path doesn't seem to be correct.
Assuming you're on a nix system, your file.txt should be right under / which seems quite unlikely to me.
If you're on a windows system the path /file.txt does not have any meaning.
Try to hardcode first your path, once it will work set it dynamically

aws s3 uploading a directory to a bucket with php sdk

This is the php file named upload.php in ec2 server
require 'vendor/autoload.php';
use Aws\S3\S3Client;
$client = S3Client::factory(array(
'key' => 'aws-secret-key',
'secret' => 'aws-very-secret-pass',
));
$dir = '/home/user/movies/history';
$bucket = 'my-unique-bucket';
$keyPrefix = '';
$options = array(
'params' => array('ACL' => 'public-read'),
'concurrency' => 20,
'debug' => true
);
$client->uploadDirectory($dir, $bucket, $keyPrefix, $options);
When I execute the upload.php file in terminal returns fatal error like this,
PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'RecursiveDirectoryIterator::__construct(/home/kaya/Resimler/transferet/): failed to open dir: No such file or directory' in /var/www/html/vendor/aws/aws-sdk-php/src/Aws/S3/Sync/UploadSyncBuilder.php:47
Stack trace:
#0 /var/www/html/vendor/aws/aws-sdk-php/src/Aws/S3/Sync/UploadSyncBuilder.php(47): RecursiveDirectoryIterator->__construct('/home/user/movie...', 12800)
#1 /var/www/html/vendor/aws/aws-sdk-php/src/Aws/S3/S3Client.php(557): Aws\S3\Sync\UploadSyncBuilder->uploadFromDirectory('/home/user/movie...')
#2 /var/www/html/upload_dir.php(21): Aws\S3\S3Client->uploadDirectory('/home/user/movie...', 'my-unique-bucket', '', Array)
#3 {main}
thrown in /var/www/html/vendor/aws/aws-sdk-php/src/Aws/S3/Sync/UploadSyncBuilder.php on line 47
Normally I can upload files clearly with php sdk except uploadfolder function. I couldnt find where is false. My php sdk version is 2.7.
I figured it out. It works on local server like xampp or something, doesnt work on remote server.

Categories