Upload a File From Dropbox Php Transfer to Folder

Permit's upload a text file to Dropbox in PHP


Here nosotros'll show you lot how to use our PHP SDK to upload a file to Dropbox. For this tutorial you'll need PHP 5 (or later) and a PHP lawmaking editor. We've used Sublime Text for our tutorials simply they will work every bit well in any IDE you lot are using.

Get Set Up

1 Log in to Temboo. If you lot don't already have an business relationship, you can register for free.

twoCreate a new .php file in your preferred editor.

3Download the Temboo PHP SDK.

4Unzip the downloaded SDK and move the resulting php-sdk folder into the same parent folder as your new, blank .php file.

5Add the Temboo PHP SDK to your script:

require 'php-sdk/src/temboo.php';

6Y'all'll demand a gratis Dropbox account. If you lot don't already have one, you tin can sign up here.

7If you lot haven't already, create a Dropbox app in the Dropbox App Panel.

When asked to choose an API, select Dropbox API. Cull the blazon of admission your application volition need: App folder or Full Dropbox. The app name tin exist whatsoever you lot like. When you're done, click Create app.

Dropbox App Console

8On the next folio, specify the callback URL below equally a Redirect URI. Make sure to replace ACCOUNT_NAME with your Temboo account proper noun.

https://ACCOUNT_NAME.temboolive.com/callback/dropbox        

To Access to Your Own Dropbox

9If you volition merely be needing access to your ain account, you tin can generate an Access Token in the Dropbox App Console. Click the Generate button in the OAuth 2 department of your app settings page.

Generating a Dropbox access token for your own account

To Access to Another User's Dropbox

10In gild to admission Dropbox accounts other than your own, you will need to consummate the OAuth process. If y'all only need access to your ain business relationship, you can skip ahead to the next department.

To brainstorm, go to Dropbox > OAuth > InitializeOAuth in the Temboo code generation library. In the INPUT department of the folio, enter the AppKey found on your app settings page inside the Dropbox App Panel.

Supplying inputs needed for Dropbox Initialize OAuth

xiClick the Generate Code button to run InitializeOAuth from the Temboo site. Curlicue downwards to the OUTPUT section of the page. Salve the CallbackID to utilize in the next steps.

Outputs returned by Initialize OAuth

12The owner of the Dropbox business relationship that your application needs to access will demand to visit the AuthorizationURL found in the OUTPUT section. They should click the Allow button on the page to grant the application permission to admission their account. Once they see a bare page in the browser, information technology's safe to close the page.

Allowing your app to access a Dropbox account

13Once permission has been granted on the AuthorizationURL page, you're ready to complete the OAuth process. Visit Dropbox > OAuth > FinalizeOAuth in the Temboo lawmaking generation library. In the INPUT section of the page, enter the AppKey and AppSecret found on your app settings page in the Dropbox App Console.

Supply the CallbackID that was returned in the OUTPUT section of the InitializeOAuth page.

Required inputs for Finalize OAuth

14Now, with all the required inputs in place, click the Generate Lawmaking push button to run FinalizeOAuth from the Temboo site. Scroll downwardly once over again to the OUTPUT section of the page. Hither you lot'll find the AccessToken you'll demand for any Dropbox processes for this user'due south account. Salve it for later.

Output returned by Finalize OAuth

Generate the Code

15 Go to the Dropbox > Files > Upload page in our code generation library. From the driblet down menu at the height of the page, select PHP.

selecting P H P as your development platform

16In the INPUT department of the folio, enter your Dropbox AccessToken. Click on Salve Profile in the upper right corner of the INPUT section to save your Dropbox credentials for easy use in other Dropbox Choreos in the futurity. Using a Temboo Profile volition as well make your code simpler and more secure.

Saving credentials to a Temboo Profile

17Enter the file location and filename for your new file in the Path field. To create a text file in the root directory of your Dropbox account, effort entering /examination.txt for your Path.

18Now supply the FileContent of your text file. Nosotros'll simply use "Hello world!".

At this point, your INPUT section should look something like this:

Required inputs to upload a file

xixWe need to tell Dropbox that our file content is plain text rather than Base64 encoded binary information. To practise so, click on OPTIONAL INPUT at the lesser of the INPUT section to reveal more input fields. In the ContentType field, enter text/manifestly. You can exit the other fields blank.

Specifying the Content Type

20Click the Generate Code push button at the bottom of the INPUT section to exam the file upload from the Temboo site. You'll run into some details about your uploaded file in the OUTPUT section. If you lot go to your binder in Dropbox, you'll see your file appear.

File metadata returned by the upload file process

Attempt Information technology Out

21Dropbox won't permit you to upload a file if in that location's already a file with the location and filename specified in the Path input. Delete your test file in Dropbox so that you can run the same code once again from your PHP application.

22Scroll down to the Code section of the Choreo page to detect the generated lawmaking.

23Copy the code snippet and paste information technology into your PHP script.

24Run the lawmaking and you observe a new file in your Dropbox from your PHP application.

What side by side?

We're all finished! This PHP application can create a text file out of any cord you might produce while coding. Check out the rest of the 2000+ Choreos in our Library and detect all sorts of valuable data that you could relieve to Dropbox.

Once you've got your code up and running, you're set up to move on and do more. From monitoring your running applications, to moving your generated Temboo lawmaking to your preferred development environment and sharing it with colleagues, collaborators and friends - nosotros've got you covered.

Need assist?

We're always happy to assist. But e-mail u.s.a. at support@temboo.com, and we'll answer your questions.


Back

smithwerflefougs.blogspot.com

Source: https://temboo.com/php/upload-to-dropbox

0 Response to "Upload a File From Dropbox Php Transfer to Folder"

Postar um comentário

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel