我正在尝试构建一个 Linkedin API 代码,但我发现了一个奇怪的错误
Fatal error: Uncaught TypeError: Argument 1 passed to Dotenv\Dotenv::__construct() must be an instance of Dotenv\Loader, string given, called in E:\xampp\htdocs\linkedinpi\examples\index.php on line 16 and defined in E:\xampp\htdocs\linkedinpi\vendor\vlucas\phpdotenv\src\Dotenv.php:31 Stack trace: #0 E:\xampp\htdocs\linkedinpi\examples\index.php(16): Dotenv\Dotenv->__construct('E:\\xampp\\htdocs...') #1 {main} thrown in E:\xampp\htdocs\linkedinpi\vendor\vlucas\phpdotenv\src\Dotenv.php on line 31
我无法复制如何解决问题。
我已按照以下步骤操作
https://github.com/zoonman/linkedin-api-php-client 和 https://github.com/zoonman/linkedin-api-php-client/tree/master/examples
我已经通过 Composer 下载了 Vendor,这是我使用的代码
include_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor/autoload.php';
use LinkedIn\Client;
use LinkedIn\Scope;
$dotenv = new Dotenv\Dotenv(dirname(__DIR__));
$dotenv->load();
session_start();
$client = new Client(
getenv('[LINKEDIN CLIENT ID]'),
getenv('[LINKEDIN CLIENT SECRET]')
);
holdtom
手掌心