我正在用PHP中的autodesk forge启动一个项目,但我得到了一个无法解决的问题。我在这个站点https://learnforge.autodesk.io/#/environment/setup/2legged中做了所有事情,用PHP和Node.js创建服务器。在节点中,我获得了成功,但我的朋友们想在php中实现它。有两个错误,我解决了一个:第一个是:
HP Fatal error: Uncaught TypeError: Argument 1 passed to Dotenv\Dotenv::create() must be an instance of Dotenv\Repository\RepositoryInterface, string given, called in /Users/.../forgeExample/server/config.php on line 14 and defined in /Users/.../forgeExample/vendor/vlucas/phpdotenv/src/Dotenv.php:83
Stack trace:
#0 /Users/.../forgeExample/server/config.php(14): Dotenv\Dotenv::create('/Users/mackleym...')
#1 /Users/.../forgeExample/server/oauth.php(14): Autodesk\ForgeServices\ForgeConfig::getForgeID()
#2 /Users/.../forgeExample/server/oauth.php(49): Autodesk\ForgeServices\AuthClientTwoLegged->__construct()
#3 /Users/.../forgeExample/index.php(8): include_once('/Users/mackleym...')
#4 {main}
thrown in /Users/.../forgeExample/vendor/vlucas/phpdotenv/src/Dotenv.php on line 83我用vlucas/phpdotenv中的帮助来解决这个问题,方法是将server/config.php中的第14行从:$dotenv = Dotenv::create(__DIR);改为$dotenv = Dotenv::createImmutable(__DIR__);
服务器运行并停止加载带有第二个错误: PHP致命错误的示例:
Uncaught Autodesk\Core\Exception\RuntimeException: The client_id specified does not have access to the api product in /Users/mackleymagalhaes/development/.../forgeExample/vendor/autodesk/core/lib/Auth/TokenFetcher.php:108
Stack trace:
#0 /Users/mackleymagalhaes/development/.../forgeExample/vendor/autodesk/core/lib/Auth/TokenFetcher.php(87): Autodesk\Auth\TokenFetcher->makeRequest('https://develop...', Array)
#1 /Users/mackleymagalhaes/development/.../forgeExample/vendor/autodesk/core/lib/Auth/OAuth2/AbstractOAuth2.php(143): Autodesk\Auth\TokenFetcher->fetch('https://develop...', 'client_credenti...', Array, Array)
#2 /Users/mackleymagalhaes/development/.../forgeExample/vendor/autodesk/core/lib/Auth/OAuth2/TwoLeggedAuth.php(15): Autodesk\Auth\OAuth2\AbstractOAuth2->fetchAccessToken('authentication/...', 'client_credenti...')
#3 /Users/mackleymagalhaes/development/.../forgeExample/server/oauth.php(38): Autodesk\Auth\OAuth2\TwoLeggedAuth->fetchToken()
#4 /Users/mackleymagalhaes/developme in /Users/mackleymagalhaes/development/.../forgeExample/vendor/klein/klein/src/Klein/Klein.php on line 954
[Thu Sep 3 16:59:07 2020] [::1]:58380 [200]: GET /api/forge/oss/buckets?id=%23 - Uncaught Autodesk\Core\Exception\RuntimeException: The client_id specified does not have access to the api product in /Users/mackleymagalhaes/development/.../forgeExample/vendor/autodesk/core/lib/Auth/TokenFetcher.php:108
Stack trace:
#0 /Users/mackleymagalhaes/development/.../forgeExample/vendor/autodesk/core/lib/Auth/TokenFetcher.php(87): Autodesk\Auth\TokenFetcher->makeRequest('https://develop...', Array)
#1 /Users/.../forgeExample/vendor/autodesk/core/lib/Auth/OAuth2/AbstractOAuth2.php(143): Autodesk\Auth\TokenFetcher->fetch('https://develop...', 'client_credenti...', Array, Array)
#2 /Users/.../forgeExample/vendor/autodesk/core/lib/Auth/OAuth2/TwoLeggedAuth.php(15): Autodesk\Auth\OAuth2\AbstractOAuth2->fetchAccessToken('authentication/...', 'client_credenti...')
#3 /Users/.../forgeExample/server/oauth.php(38): Autodesk\Auth\OAuth2\TwoLeggedAuth->fetchToken()
#4 /Users/mackleymagalhaes/developme in /Users/mackleymagalhaes/development/.../forgeExample/vendor/klein/klein/src/Klein/Klein.php on line 954有人知道这是什么吗?
将vlucas/phpdoenv的版本降级为^3.0.0后,控制台上出现了以下错误:
12:12:13 2020 / ..\forge-example2\vendor\autodesk\forge-client\lib\ApiClient.php:261 /
/oss/桶-没有这样的文件或目录Tue Sep 8 09:12:14 2020 PHP al error: Uncaught \forge\client\ApiException: 403错误连接到S tack跟踪中的API (https://developer.api.autodesk.com/oss/v2/buckets):#0 . file 2\供应商\ Autodesk\ forge client\lib\Api\抽象Api.php(89):Autodesk\Forge\Client\ApiClient->callApi('/oss/v2/buckets','GET',Array,'',Array,‘\autodesk\Forge.,’/oss/v2/水桶‘) #1 .\伪造-伪造-供应商\autodesk\伪造-cl ient\lib\Api\BucketsApi.php(390):ient\lib\Api\BucketsApi.php水桶,'GET',数组,’,数组,‘\autodesk\Forge.,#2 ..\forge-example2\vendor\autodesk\forge-client\lib\Api \BucketsApi.php(330):Autodesk\Forge\Client\Api\BucketsApi->getBucketsWithH ttpInfo(NULL,NULL,Autodesk\Forge\Client\Api\BucketsApi->getBuckets() #4 D:\UFU\for ge-example2\index.php(26):Autodesk\ForgeS ervices\DataManagement->getBucketsAndObjects() #5 [ ..\forge-example2\vendor\klein\klein\src\Klein\Klein.php中的内部乐趣在第954行
Sep 8 09:12:14 2020:54087 200: GET / API /Forge/oss/ iClient.php:261 ?id=%23- Uncaught \Forge\client\ApiException: 403错误连接到D中的API (https://developer.api.autodesk.com/oss/v2/buckets):\UFU\trace 2\iClient.php:261\Forge\Forge\iClient.php:261 Stack跟踪:#0 iClient.php:261 \AbstractApi.php(89):Autodesk\Forge\C lient\ApiClient->callApi(‘/oss/v2/水桶’,'GET',数组,‘,数组,’\Autodesk\Forge‘,’/oss/v2/桶‘) #1 .\伪造-考试ple2\vendor\autodesk\forge-client\lib\Api\BucketsApi.php(390):Autodesk\Forge\Client\Api\Abst ractApi->callApi(’/oss/v2/bucket‘,'GET',Array,数组,’\Autodesk\Forge.‘,'/oss/v2/b ucket‘) #2 .\Forge 2\供应商\auto desk\forge-client\lib\Api\BucketsApi.php(330):\Forge\Client\Api\BucketsApi->getBuc ketsWithHttpInfo(NULL,NULL,( NULL) #3 ..\forge example2\server\oss.php(47):Autodesk\Forge\Client\Api\BucketsApi->getBuckets() #4 .\forge example2\index.php(26):Aut odesk\ForgeServices\DataManagement->getBucketsAndObjects() #5 [内部乐趣在D:\UFU\forge ex ample2\vendor\klein\klein\src\Klein\Klein.php (第954行)
2010年9月8日09:12:14 2020:54087关闭
发布于 2020-09-04 10:54:38
我遇到了同样的问题,在我的例子中,结果是vlucas/phpdotenv依赖项的版本不匹配。下面是我使用PHP示例所做的工作(在项目的根文件夹中,使用bash):
# confirm you have a good version of PHP (in my case it's 7.3.11)
php -v
# remove composer dependencies
rm -rf vendor
rm composer.lock
# setup composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
php composer.phar install
# create the .env file
cp server/.env.example server/.env
vim server/.env # add your client ID and client secret
# start the app
php -S localhost:3000 -t .
# now, open your browser and go to http://localhost:3000/www/index.htmlhttps://stackoverflow.com/questions/63731074
复制相似问题