autodesk/forge-client
最新稳定版本:v1.0.3
Composer 安装命令:
composer require autodesk/forge-client
包简介
README 文档
README
Forge PHP SDK
Overview
This PHP SDK enables you to easily integrate the Forge REST APIs into your application, including OAuth, Data Management, Model Derivative, and Design Automation.
Requirements
- PHP version 5.4.0 and above.
- A registered app on the Forge Developer portal.
Installation
Composer
To install the bindings via Composer, run:
composer require autodesk/forge-client
Manual Installation
Download the files and include autoload.php:
require_once('/path/to/ForgeClient/autoload.php');
Tutorial
Follow this tutorial to see a step-by-step authentication guide, and examples of how to use the Forge APIs.
Create an App
Create an app on the Forge Developer portal. Note the client ID and client secret.
Authentication
This SDK comes with an OAuth 2.0 client that allows you to retrieve 2-legged and 3-legged tokens. It also enables you to refresh 3-legged tokens. The tutorial uses 2-legged and 3-legged tokens for calling different Data Management endpoints.
2-Legged Token
This type of token is given directly to the application.
To get a 2-legged token run the following code. Note that you need to replace your-client-id and your-client-secret with your app's client ID and client secret.
<?php Autodesk\Auth\Configuration::getDefaultConfiguration() ->setClientId('<your-client-id>') ->setClientSecret('<your-client-secret>'); $twoLeggedAuth = new Autodesk\Auth\OAuth2\TwoLeggedAuth(); $twoLeggedAuth->setScopes(['bucket:read']); $twoLeggedAuth->fetchToken(); $tokenInfo = [ 'applicationToken' => $twoLeggedAuth->getAccessToken(), 'expiry' => time() + $twoLeggedAuth->getExpiresIn(), ];
3-Legged Token
Generate an Authentication URL
To ask for permissions from a user to retrieve an access token, you redirect the user to a consent page.
Replace your-client-id, your-client-secret, and your-redirect-url with your app's client ID, client secret, and redirect URL, and run the code to create a consent page URL.
Note that the redirect URL must match the callback URL you provided when you created the app.
<?php Autodesk\Auth\Configuration::getDefaultConfiguration() ->setClientId('<your-client-id>') ->setClientSecret('<your-client-secret>') ->setRedirectUrl('<your-redirect-url>'); $threeLeggedAuth = new Autodesk\Auth\OAuth2\ThreeLeggedAuth(); $threeLeggedAuth->addScope('code:all'); $authUrl = $threeLeggedAuth->createAuthUrl();
Retrieve an Authorization Code
Once a user receives permissions on the consent page, Forge will redirect the page to the redirect URL you provided when you created the app. An authorization code is returned in the query string.
GET /callback?code={authorizationCode}
Retrieve an Access Token
Request an access token using the authorization code you received, as shown below:
<?php Autodesk\Auth\Configuration::getDefaultConfiguration() ->setClientId('<your-client-id>') ->setClientSecret('<your-client-secret>') ->setRedirectUrl('<your-redirect-url>'); $threeLeggedAuth = new Autodesk\Auth\OAuth2\ThreeLeggedAuth(); $threeLeggedAuth->addScope('code:all'); $threeLeggedAuth->fetchToken($_GET['code']); $userToken = [ 'accessToken' => $threeLeggedAuth->getAccessToken(), 'refreshToken' => $threeLeggedAuth->getRefreshToken(), 'expiry' => time() + $threeLeggedAuth->getExpiresIn(), ];
Note that access tokens expire after a short period of time. The expires_in field gives the validity of an access token in seconds.
To refresh your access token, call the $threeLeggedAuth->refreshToken($refreshToken); method.
Example API Calls
Use the TwoLeggedAuth object or the ThreeLeggedAuth object to call the Forge APIs.
<?php $apiInstance = new Autodesk\Forge\Client\Api\ActivitiesApi($threeLeggedAuth); $activity = new \Autodesk\Forge\Client\Model\Activity(); // \Autodesk\Forge\Client\Model\Activity $result = $apiInstance->createActivity($activity);
API Documentation
You can get the full documentation for the API on the Developer Portal
Documentation for API Endpoints
All URIs are relative to https://developer.api.autodesk.com. For example, the createActivity URI is 'https://developer.api.autodesk.com/autocad.io/us-east/v2/Activities'.
Thumbnail
Support
autodesk/forge-client 适用场景与选型建议
autodesk/forge-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 154.44k 次下载、GitHub Stars 达 41, 最近一次更新时间为 2017 年 04 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「api」 「sdk」 「swagger」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 autodesk/forge-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 autodesk/forge-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 autodesk/forge-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Alfabank REST API integration
Zero-dependency raw PHP DNS resolver, domain-ownership verification, and intoDNS/MxToolbox-style diagnostics. Queries authoritative nameservers directly over sockets — never trusts the recursive cache for ownership checks.
A lightweight plain-PHP framework for database-backed CRUD APIs.
bughq error tracking - PHP SDK
ABsurge PHP SDK for feature flags and A/B testing
统计信息
- 总下载量: 154.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 41
- 点击次数: 13
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2017-04-02