2012-04-16 64 views
1

我是新来的C#和Windows Phone 7的开发和试图使用Dropnet API,我得到一个错误:ArgumentNullException了未处理

using DropNet; 

namespace Hello 
{ 

public partial class App : Application 
{ 
    public PhoneApplicationFrame RootFrame { get; private set; } 

    public static DropNetClient DropNetClient { get; set; } 

    public App() 
    { 

     InitializeComponent(); 

     InitializePhoneApplication(); 

     DropNetClient = new DropNetClient("api key", "secret"); 
//I've correct app key and secret inserted here 

     DropNetClient.GetTokenAsync((userLogin) => 
     { 
      //Dont really need to do anything with userLogin, 
//DropNet takes care of it for now 
     }, 
    (error) => 
    { 
     //Handle error 
    }); 

     var url = DropNetClient.BuildAuthorizeUrl(); 
//getting error here 


    } 
} 

我得到的错误是

ArgumentNullException was unhandled
Value cannot be null
Parameter name: userLogin

根据http://dkdevelopment.net/what-im-doing/dropnet/该代码应该工作。请帮忙。

_client = new DropNetClient("API KEY", "API SECRET", "USER TOKEN", "USER SECRET"); 
// OR 
_client = new DropNetClient("API KEY", "API SECRET"); 
_client.UserLogin = new UserLogin { Token = "USER TOKEN", Secret = "USER SECRET" }; 

你错过了用户登陆初始化:

回答

0

从您提供的链接引用。

+0

我认为我们在第二次登录后,用户登录一次(并且应用程序存储了令牌和密码)后,我们使用'user token'和'user secret'。首次登录问题中的代码应该是正确的。 只是来自Java背景,我有点难以理解这里发生了什么。 :) – 2012-04-16 16:50:07

+0

你应该把用户带到dropbox认证页面,在那里他可以登录和授权你的应用程序。然后,您检索用户令牌和用户密码,然后您可以使用它们。这是您链接的网站上的第2步和第2.5步。 – 2012-04-16 17:16:54