<C#>Dropbox APIs

第一步,激活Drive API

首先,申请Dropbox的帐号;其次,在Dropbox for Developers上获得开发所需的App
Key和App Sercet。

1、登录Dropbox for
Developers
网站;2、点击App Console选项,选择Create app;3、点击Send email for
verification;4、通过电子邮件验证;5、在Create a new Dropbox Platform app上,选择Dropbox API
app;6、填写信息并Create app,就将获得App key和App secret。

第二步,安装Dropbox Client Library

安装一个NuGet包(Dropnet)。如VS2012选择Tools项,再选NuGet Package Manager,接着Package Manager
Console。在PM>中填写Install-Package dropnet -Pre。

第三步,编程


 1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.Text;
8 using System.Windows.Forms;
9 using DropNet;
10
11 namespace DropNetDemo
12 {
13 public partial class Form1 : Form
14 {
15 #region Var
16 private DropNetClient _dropNetClient;
17 #endregion
18
19 #region Private Property
20 private DropNetClient m_DropNetClient
21 {
22 get
23 {
24 return _dropNetClient ?? (_dropNetClient = new DropNetClient(tbxAppKey.Text, tbxAppSecret.Text));
25 }
26 set
27 {
28 _dropNetClient = value;
29 }
30 }
31 #endregion
32
33 public Form1()
34 {
35 InitializeComponent();
36 }
37
38 private void btnLogin_Click(object sender, EventArgs e)
39 {
40 var callbackUrl = "https://www.dropbox.com/1/oauth/authorize";
41 var cancelCallbackUrl = "https://www.dropbox.com/home";
42 var size = new Size(1024, 600);
43
44 if (DoOAuth(callbackUrl, cancelCallbackUrl, size) == DialogResult.OK)
45 {
46 var accessToken = m_DropNetClient.GetAccessToken();
47 }
48 }
49
50 private DialogResult DoOAuth(string callbackUrl, string cancelCallbackUrl, System.Drawing.Size size)
51 {
52 using (var dialog = new Form())
53 {
54 var browesr = new WebBrowser()
55 {
56 Dock = DockStyle.Fill
57 };
58
59 m_DropNetClient.GetToken();
60 var authUrl = m_DropNetClient.BuildAuthorizeUrl();
61 browesr.Navigated += (s, ex) =>
62 {
63 var url = ex.Url.ToString();
64 if (url.Equals(callbackUrl))
65 {
66 dialog.DialogResult = DialogResult.OK;
67 }
68 else if (url.Equals(cancelCallbackUrl))
69 {
70 dialog.DialogResult = DialogResult.Cancel;
71 }
72 };
73 browesr.Navigate(authUrl);
74
75 dialog.Size = size;
76 dialog.Controls.Add(browesr);
77
78 return dialog.ShowDialog();
79 }
80 }
81
82 private void tbxAppKey_TextChanged(object sender, EventArgs e)
83 {
84 m_DropNetClient = null;
85 }
86
87 private void tbxAppSecret_TextChanged(object sender, EventArgs e)
88 {
89 m_DropNetClient = null;
90 }
91 }
92 }

最后,F5运行
源自:http://www.dotblogs.com.tw/larrynung/archive/2012/07/24/73580.aspx

http://www.dotblogs.com.tw/larry/nung/archive/2012/08/08/73912.aspx

<C#>Dropbox APIs,布布扣,bubuko.com

时间: 2025-01-19 21:04:34

<C#>Dropbox APIs的相关文章

Kernel logging: APIs and implementation

Kernel API Logging within the kernel is performed using the printk function int printk( const char * fmt, ... ); The kernel code simply defines the log level as the first argument of the message, as illustrated in the following example for a critical

中国版dropbox“坚果云”和它背后的团队故事

(速途网专栏 作者:娄昊川)坚果云是一款中文存储服务,前身是“坚果铺子”,提供免费的云空间,与dropbox类似,用户可以直接把档案同步到坚果云,供自己和伙伴用任何设备访问.自上线以来,几乎所有用户都反映该产品满足了他们很多需求,那这个产品背后的精神和团队究竟有着怎样有趣的故事. 今天我们采访了坚果云的两位创始人,同样也是坚果云的打造者,蔺皓和杨剑: Teambition:坚果云和dropbox是最像的,同步性能都非常好,想比之下坚果云最大的优势在哪里? 蔺皓:dropbox也是一款存储个人数据

[Node.js] Creating Demo APIs with json-server

json-server makes it extremely easy to setup robust JSON apis to use for demos and proof of concepts. John walks you through the process of using pre-built json files for a server and how to generate larger datasets using lodash and faker. Install: n

APPCORE Routine APIs

Introduction to APPCORE Routine APIs This chapter provides you with specifications for calling many Oracle E-Business Suite APIs from your PL/SQL procedures. Most routines in the APPCORE library are described here. Some APPCORE routines are described

BEGINNING SHAREPOINT&#174; 2013 DEVELOPMENT 第9章节--客户端对象模型和REST APIs概览 Windows Phone

BEGINNING SHAREPOINT? 2013 DEVELOPMENT 第9章节--客户端对象模型和REST APIs概览 Windows Phone 和.NET托管代码和JavaScript CSOMs一样,CSOM库对于Windows Phone和Silverlight同样可用.

在Dropbox上搭建私有的Git仓库的教程

导读 Git版本控制系统需要一个服务器端,而GitHub上要想创建私有的Git服务器端仓库则触及到收费项目,于是这里我们利用Dropbox的免费空间,来看一下在Dropbox上搭建私有的Git仓库的教程. 一.在Dropbox的文件夹下创建远程repository文件夹(.git后缀) cd ~/Dropbox/project mkdir demo.git 二.进入demo.git文件夹并初始化repository cd demo.git git init --bare 三.创建完毕,现在创建一

用Flask 搭建RESTful APIs 服务器端

此文摘录自: http://www.cnblogs.com/vovlie/p/4178077.html 最近这些年,REST已经成为web services和APIs的标准架构,很多APP的架构基本上是使用RESTful的形式了. 本文将会使用python的Flask框架轻松实现一个RESTful的服务. REST的六个特性: Client-Server:服务器端与客户端分离. Stateless(无状态):每次客户端请求必需包含完整的信息,换句话说,每一次请求都是独立的. Cacheable(

Oracle Inventory Management Application Program Interface ( APIs) (Doc ID 729998.1)

In this Document Goal Solution References APPLIES TO: Oracle Inventory Management - Version 12.0.0 and later Information in this document applies to any platform. This document includes all versions R12.x.x and later. ***Checked for relevance on 22-O

BEGINNING SHAREPOINT&#174; 2013 DEVELOPMENT 第9章节--客户端对象模型和REST APIs概览 REST和ODATA

BEGINNING SHAREPOINT? 2013 DEVELOPMENT 第9章节--客户端对象模型和REST APIs概览 REST和ODATA REpresentational State Transfer (REST)是设计通过Internet网络简单消费数据的普遍模式.