i am using dirkgroenen library php for authorization of my app and create board
which i downloaded from here
https://github.com/dirkgroenen/Pinterest-API-PHP
evry time i run this code it gives me uncaught error about the line:8
Fatal error: Uncaught Error: Class 'Dotenv\Dotenv' not found in C:\xampp\htdocs\pin\vendor\demo\boot.php:8
here is the code for boot.php
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require ("../autoload.php");
$dotenv = new Dotenv\Dotenv(__DIR__);
$dotenv->load();
$pinterest = new
DirkGroenen\Pinterest\Pinterest(getenv("4915445646307112766"),
getenv("1ae8683b277958bd9739cedb0f0b1434eee42176dd3d44cbf44981f9acaadd94"));
if (isset($_GET["code"]))
{
$token = $pinterest->auth->getOAuthToken($_GET["code"]);
$pinterest->auth->setOAuthToken($token->access_token);
setcookie("access_token", $token->access_token);
}
else if (isset($_GET["access_token"]))
{
$pinterest->auth->setOAuthToken($_GET["access_token"]);
}
else if (isset($_COOKIE["access_token"]))
{
$pinterest->auth->setOAuthToken($_COOKIE["access_token"]);
}
else
{
assert(false);
}
?>
can anyone please help me to fix it.. i have spent more than 48 hours to resolve this issue..
any help will be greatly appreciated
Obviously, you don't have Dotenv class anywhere where PHP expects it to be found.
Options:
You don't have it at all, then download it from here: vlucas/phpdotenv. Composer should have downloaded it, BUT only if you used composer to install DirkGroenen.
You have it but it is outside autoload path - check autoload path, make sure that Dotenv is located in appropriate vendor-folder.
You have it but it doesn't support autoload (sic!) - check with latest version OR include it directly with include/require
It requires phpunit/phpunit to be installed aswell.
Related
I am trying to connect zoho crm to my website to read data. I cannot get past the title error.
I have installed the sdk in my folder through composer require zohocrm/php-sdk. I am also including the name space at the top of the file use zcrmsdk\crm\setup\restclient\ZCRMRestClient;. So I am not sure what else to try. There is very little documentation on this sdk.
Thanks
This is my php file
<?php
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
// session_start();
require 'vendor\autoload.php';
$configuration=array("client_id"=>"1000.<client_ID>","client_secret"=>"<client_secret>","redirect_uri"=>"www.google.com","currentUserEmail"=>"marktok206#gmail.com");
ZCRMRestClient::initialize($configuration);
echo "working rn";
?>
This is my .json file
{
"require": {
"zohocrm/php-sdk": "^3.1"
}
}
Well I'm stumped. I've been trying to work this out for several hours, plenty of Googles later and nothing. /rant.
I'm new to Auth0 and figured I'd give it a go but I'm getting the error below. I'm using their PHP sample project which you can find here: https://github.com/auth0-samples/auth0-php-web-app/tree/master/00-Starter-Seed/basic-webapp
I've installed composer and installed the dependencies. I've renamed ensured that I have .env setup correctly. I'm running this in XAMPP.
Fatal error: Uncaught Error: Class 'Dotenv\Dotenv' not found in /Users/.../htdocs/oa/dotenv-loader.php:6
I've tried different varations of the dotenv-loader.php show below but with no luck. Does anyone have any advice?
try {
$dotenv = new Dotenv\Dotenv(__DIR__);
$dotenv->load();
} catch(InvalidArgumentException $ex) {
// Ignore if no dotenv
}
// Read .env
$dotenv = new Dotenv\Dotenv('.env');
if(file_exists(".env")) {
$dotenv->load();
}
$dotenv = new Dotenv\Dotenv(__DIR__);
//Check if file exists the same way as dotenv does it
//See classes DotEnv\DotEnv and DotEnv\Loader
//$filePath = $dotenv->getFilePath(__DIR__);
//This method is protected so extract code from method (see below)
$filePath = rtrim(__DIR__, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR . '.env';
if(is_file($filePath) && is_readable($filePath)) {
$dotenv->load();
}
Thanks a lot in advance.
Upon reading Google's login API, I realised you need to run 'composer install' where ever you composer.json is located, this seems to have fixed the issue. I'll update this should this not be the case.
I keep getting this error when I am trying to test Faker PHP from github on my server:
Fatal error: Class 'Faker\Provider\en_US\Address' not found in /home/andrew/public_html/JeffWork/src/Faker/Provider/en_US/Address.php on line 6
Link: http://aswanson.net/JeffWork/test/test.php
All of the package files have been installed and uploaded properly, and the code on line 5 & 6 looks like:
class Address extends \Faker\Provider\en_US\Address
{
Please make sure whether the file exists in the folder where your referring for "/home/andrew/public_html/JeffWork/src/Faker/Provider/en_US/Address.php".
Please take a new update with composer with the following
composer require fzaninotto/faker
Now with the updated version 1.6, you will be able to solve this kind of issue make sure to use autoload.php in file where your using.
The following shows the snippet of usage
<?php
require_once 'vendor/autoload.php';
$faker = Faker\Factory::create();
$person = new Faker\Provider\en_US\Person($faker);
$address = new Faker\Provider\en_US\Address($faker);
foreach(range(1,10) as $i){
echo $address->address(),'<br/>';
}
Cheers!
I'm a google recaptcha v2 on a local machine running wamp. Everything looks fine except it keeps dying when its supposed to validate the form
I'm getting this error:
Fatal error: Class 'ReCaptcha\RequestMethod\Post' not found in C:\wamp\www\php\contactForm\Captcha\ReCaptcha.php on line 73
I've pretty much copy/pasted the example code from google:
if (!empty($human)) {
require_once('Captcha\ReCaptcha.php');
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
$resp = $recaptcha->verify($human, $remoteIp);
if ($resp->isSuccess()) {
// verified!
I've downloaded the files from the google github (https://github.com/google/recaptcha/tree/master/src/ReCaptcha) and just used the folder /files names as they came. I've got my validation file one folder above but I've also tried coping the files into the same folder as my validation script just in case.
Any ideas?
It seems google bank on the fact that everyone use composer to install their repository. And to be honest that is the only installation method they give on thier github repo readme.md https://github.com/google/recaptcha
When you install a package such as google recaptcha with composer the package has the option to register with an autoloader in https://github.com/google/recaptcha/blob/master/composer.json
"autoload": {
"psr-4": {
"ReCaptcha\\": "src/ReCaptcha"
}
},
This way all you have to include in your script to get access to all your package classes is the autoload.php that composer generates when it installs your packages.
Line 34: https://github.com/google/recaptcha/blob/master/examples/example-captcha.php
// Initiate the autoloader.
require_once __DIR__ . '/../vendor/autoload.php';
An autoloader is a function that tries to load a class when php is asked for it. And in this case it kind of maps a namespace to a directory structure on the disk.
More about php autoloaders here: http://php.net/autoload and here: http://www.php-fig.org/psr/psr-4/examples/
If you do not wish to use composer and its autoload functionality, you may find this useful: https://github.com/abraham/twitteroauth it has an autoload.php which you could borrow which can load classes without composer.
Place a copy of it in your recaptcha top level folder (the one with README.md in it)
Replace line 12 with $prefix = 'ReCaptcha\\';
replace line 15 with $base_dir = __DIR__ . '/src/ReCaptcha/';
Require autoloader.php (this file) in your code somewhere
Instantiate your ReCaptcha object something like this in your code
new ReCaptcha\ReCaptcha($RECAPTCHASECRETKEY);
I hope I don't get slammed to hard but I found if you require all of the files it works as designed without using an autoloader or composer.
//GOOGLE RECAPTCH CODE
require_once('/cgi-bin/src/ReCaptcha/ReCaptcha.php');
require_once('/cgi-bin/src/ReCaptcha/RequestMethod.php');
require_once('/cgi-bin/src/ReCaptcha/RequestParameters.php');
require_once('/cgi-bin/src/ReCaptcha/Response.php');
require_once('/cgi-bin/src/ReCaptcha/RequestMethod/Post.php');
require_once('/cgi-bin/src/ReCaptcha/RequestMethod/Socket.php');
require_once('/cgi-bin/src/ReCaptcha/RequestMethod/SocketPost.php');
$gRecaptchaResponse = $_POST['g-recaptcha-response'];
$secret = 'YOUR SECRET KEY';
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
$resp = $recaptcha->verify($gRecaptchaResponse, $remoteIp);
if ($resp->isSuccess()) {
//DO ACTION IF SUCCESSFUL
} else {
$errors = $resp->getErrorCodes();
}
//END OF GOOGLE RECAPTCHA CODE
I am trying to use NetDNA to purge cached URLS from MaxCDN and not able to create the NetDNA object - gives me the following error message:
Fatal error: Class 'NetDNA' not found in purgeCacheDev.php on line 8
Any ideas where to look to resolve this error ?
<?php
ini_set("display_errors",1);
error_reporting(E_ALL);
require_once '../vendor/autoload.php';
$api = new NetDNA("aaa","bbb","ccc");
// get account information
echo $api->get('/account.json');
exit;
?>
Try this:
php composer.phar update -o
within your project folder.
Also make sure your IP(s) are whitelisted: http://support.maxcdn.com/tutorials/how-to-whitelist-your-server-ip-to-use-the-api/