Dropbox在iPhone应用程序中的集成错误400

Cla*_*nce 4 iphone objective-c dropbox ipad ios

我使用了很棒的源代码GSDropboxDemoApp,它很好地将Dropbox集成到应用程序中.但是,在将应用程序链接到Dropbox之后,它在加载文件夹内容时出错.以下是代码

我已经编辑了info.plist

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#warning Potentially incomplete method implementation. Fill in your Dropbox credentials!
#warning NB: you must also update the URL scheme listed under the CFBundleURLTypes key in GSDropboxDemoApp-Info.plist
    NSString *dropboxAppKey = @"sxxxxxxxxxx";
    NSString *dropboxAppSecret = @"cxxxxxxxxx";
    NSString *dropboxRoot = @"kDBRootAppFolder";  // either kDBRootAppFolder or kDBRootDropbox

    DBSession* dbSession = [[DBSession alloc] initWithAppKey:dropboxAppKey
                                                   appSecret:dropboxAppSecret
                                                        root:dropboxRoot];
    [DBSession setSharedSession:dbSession];

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.viewController = [[GSViewController alloc] initWithNibName:@"GSViewController" bundle:nil];
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    if ([[DBSession sharedSession] handleOpenURL:url]) {
        if ([[DBSession sharedSession] isLinked]) {
            NSLog(@"App linked to Dropbox successfully");
        } else {
            NSLog(@"App not linked to Dropbox!");
        }
        return YES;
    }
    return NO;
}
Run Code Online (Sandbox Code Playgroud)

错误信息

 GSDropboxDemoApp[4674:907] [WARNING] DropboxSDK: error making request to /1/metadata/kDBRootAppFolder - (400) Expected a root of either 'dropbox' or 'sandbox', got 'kDBRootAppFolder'
Run Code Online (Sandbox Code Playgroud)

lxt*_*lxt 8

您应该使用常量,如下所示:

NSString *dropboxRoot = kDBRootAppFolder;  // either kDBRootAppFolder or kDBRootDropbox
Run Code Online (Sandbox Code Playgroud)

使用常量,这样您就不必担心实际值本身.