Note: For using this sample, you need a valid oAuth credential. Visit this page for instructions to get on-board.
This sample exercises the PHP7 engine to demonstrate the Forge OAuth authorisation process and most of the Forge Services API such as Data Management, BIM360, Viewer, ...
Demonstrates the use of the Autodesk Forge API using a PHP7 application. Supports both 2 legged and 3 legged protocols.
- Forge Account: Learn how to create a Forge Account, activate subscription and create an app at this tutorial.
- Visual Studio Code: other text editors could be used too, but Visual Studio Code is a widely used editor, see https://code.visualstudio.com/.
- PHP7: basic knowledge of PHP, see https://php.net/.
- JavaScript: basic knowledge.
- If you want to use the BIM360 API - BIM 360 or other Autodesk storage account: if you want to use it with files from BIM 360 Docs then you must be an Account Admin to add the app integration. Learn about provisioning.
-
Install PHP7
-
Download (fork, or clone) this project
-
Install PHP dependency modules:
php composer.phar install
-
Request your consumer client/secret keys from https://forge.autodesk.com.
-
Note for the 3 legged sample: while registering your keys, make sure that the callback you define for your callback (or redirect_uri) match your localhost and PORT number.
-
Provision your application key on the BIM360 application integration page. Learn about provisioning. This step is not required for Fusion Team.
-
Open the /server/.env file and set your data
-
If using mySQL vs PHP_SESSION
a. Edits /server/2legged-oauth.php at #41 #42
b. Edits /server/3legged-oauth.php at #37 #38
c. Create the mySQL table in your database - create statement here
-
You can choose you default model by changing the URNs - for 2 legged here and for 3 legged here
-
For 3 legged, specify your BIM360 or Fusion Team HUB and PROJECT IDs here
Note: To find your URN, hub_id, project_id, folder_id version_id, you can use the '/api/forge/public/3hubs-tree' endpoint.
- call http://localhost/api/forge/public/3hubs-tree which will give you the list of hubs and projects. Choose the pair you want to use.
- call the same endpoint with hub_id and project_id parameters, like this: 'http://localhost/api/forge/public/3hubs-tree?hub_id=a.YnVzaW5lc3M6ZnJlZTM4ODc&project_id=a.YnVzaW5lc3M6ZnJlZTM4ODcjMjAyMDA3MTUzMTU4OTMyODE' - replace values with yours from step 1.
Note: Edit the server/.env file and replace the placeholders by the values listed above.
To use the 2legged version, just got to the root of your server, for example http://localhost/
To use the 3legged version, go to http://localhost/login for creating a new pair of tokens, otherwise go to http://localhost/www/view.html. When using the /login option, you willbe redirected to /www/view.html after authentication.
Documentation:
Tutorials:
Blogs:
- Forge Blog
- Field of View, a BIM focused blog
This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.
Cyrille Fauvel
Forge Developer Advocacy and Support
https://forge.autodesk.com/
https://around-the-corner.typepad.com