iphone照片上传应用程序

时间:2014-04-10 04:25:04

标签: ios objective-c flickr

我正在开发一款照片上传应用。我想在flickr上传照片。我使用了来自lukhnos / objectiveflickr·GitHub的Objectiveflickr框架,我的代码与snap和run相同。当我将callbackurl设置为“snapnrun:// auth”时,它运行良好但是一旦我更改了回调url,我就会收到错误。我无法进行身份验证并将用户返回到应用程序屏幕。 这是我的一段代码

#import "AppDelegate.h"
#import "loginviewController.h"
#import "RegisterViewController.h"
#import "HomeViewController.h"
#import "Constant.h"
#import "CollectionViewController.h"

NSString *SnapAndRunShouldUpdateAuthInfoNotification = @"SnapAndRunShouldUpdateAuthInfoNotification";

// preferably, the auth token is stored in the keychain, but since working with keychain is a pain, we use the simpler default system
NSString *kStoredAuthTokenKeyName = @"FlickrOAuthToken";
NSString *kStoredAuthTokenSecretKeyName = @"FlickrOAuthTokenSecret";

NSString *kGetAccessTokenStep = @"kGetAccessTokenStep";
NSString *kCheckTokenStep = @"kCheckTokenStep";

NSString *SRCallbackURLBaseString = @"myapp://authentication";
@implementation AppDelegate


- (OFFlickrAPIRequest *)flickrRequest
{
    if (!flickrRequest) {
        flickrRequest = [[OFFlickrAPIRequest alloc] initWithAPIContext:self.flickrContext];
        flickrRequest.delegate = self;
    }

    return flickrRequest;
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    if ([self flickrRequest].sessionInfo) {
        // already running some other request
        NSLog(@"Already running some other request");
    }
    else {
        NSString *token = nil;
        NSString *verifier = nil;
        BOOL result = OFExtractOAuthCallback(url, [NSURL URLWithString:SRCallbackURLBaseString], &token, &verifier);
        //[flickrRequest fetchOAuthRequestTokenWithCallbackURL:[NSURL URLWithString:SRCallbackURLBaseString]];
       if (!result) {
        NSLog(@"Cannot obtain token/secret from URL: %@", [url absoluteString]);
        return NO;
        }

        [self flickrRequest].sessionInfo = kGetAccessTokenStep;
        [flickrRequest fetchOAuthAccessTokenWithRequestToken:token verifier:verifier];
       [activityIndicator startAnimating];
       // [viewController.view addSubview:progressView];

    }

    return YES;
}


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

   // [window addSubview:viewController.view];
   // [window makeKeyAndVisible];
    if([self.flickrContext.OAuthToken length]){
        [self flickrRequest].sessionInfo = kCheckTokenStep;
        [flickrRequest callAPIMethodWithGET:@"flickr.test.login" arguments:nil];

        [activityIndicator startAnimating];
        [viewController.view addSubview:progressView];

    }

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];

    [UIApplication sharedApplication].applicationIconBadgeNumber = 0;

    HomeViewController *homeViewController = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil];

    CollectionViewController *collection = [[CollectionViewController alloc]initWithNibName:@"CollectionViewController" bundle:nil];

    UINavigationController *navigationHome = [[UINavigationController alloc] initWithRootViewController:collection];

    self.tabbarController = [[UITabBarController alloc] init];
    self.tabbarController.viewControllers = [NSArray arrayWithObjects:navigationHome,homeViewController,rvc,nil];

    login = [[loginviewController alloc] initWithNibName:@"loginviewController" bundle:nil];

    if ([[NSUserDefaults standardUserDefaults] boolForKey:Key_Login_Status]) {
        self.window.rootViewController = self.tabbarController;
        }

           else {
        self.window.rootViewController = login;
    }

        [self.window makeKeyAndVisible];
    return YES;
}

请告诉我如何解决这个问题? 谢谢你的回复

0 个答案:

没有答案