无法导入ios应用程序中的yahoo联系人收到BadExcess错误

时间:2012-10-12 10:20:17

标签: objective-c ios yahoo-api

我已从https://github.com/yahoo/yos-social-objc下载了此项目。 我更改了ConsumerKey, ConsumerSecret 和ApplicationId但当我运行应用程序时它崩溃了。它给出了BAD-Excess的错误。 有没有人知道这个? 请指教 谢谢 基本上它刚从雅虎的开发者页面下载的项目仍在。 这是我的完整代码 SocialSampleAppDelegate.h 文件

#import <UIKit/UIKit.h>
#import "YOSSession.h"

@class SocialSampleViewController;

@interface SocialSampleAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    SocialSampleViewController *viewController;

    YOSSession                  *session;
    NSMutableDictionary         *oauthResponse;
    BOOL                        launchDefault;
}

    @property BOOL launchDefault;
    @property (nonatomic, readwrite, retain) YOSSession *session;
    @property (nonatomic, readwrite, retain) NSMutableDictionary *oauthResponse;

    @property (nonatomic, retain) IBOutlet UIWindow *window;
    @property (nonatomic, retain) IBOutlet SocialSampleViewController *viewController;

    - (void)getUserProfile;
    - (void)createYahooSession;
    - (void)handlePostLaunch;

    @end

SocialSampleAppDelegate.m

#import "SocialSampleAppDelegate.h"
#import "SocialSampleViewController.h"

#import "YOSUser.h"
#import "YOSUserRequest.h"
#import "NSString+SBJSON.h"

@implementation SocialSampleAppDelegate

@synthesize window;
@synthesize viewController;
@synthesize session;
@synthesize launchDefault;
@synthesize oauthResponse;


    - (void)applicationDidFinishLaunching:(UIApplication *)application {    

        // Override point for customization after app launch    
        [window addSubview:viewController.view];
        [window makeKeyAndVisible];

        launchDefault = YES;
        [self performSelector:@selector(handlePostLaunch) withObject:nil afterDelay:0.0];
    }

    - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url 
    {
        launchDefault = NO;

        if (!url) { 
            return NO; 
        }

        NSArray *pairs = [[url query] componentsSeparatedByString:@"&"];
        NSMutableDictionary *response = [NSMutableDictionary dictionary];

        for (NSString *item in pairs) {
            NSArray *fields = [item componentsSeparatedByString:@"="];
            NSString *name = [fields objectAtIndex:0];
            NSString *value = [[fields objectAtIndex:1]   stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

            [response setObject:value forKey:name];
        }

        self.oauthResponse = response;

        [self createYahooSession];

        return YES;
    }

    - (void)handlePostLaunch
    {
        if(self.launchDefault) {
            [self createYahooSession];
        }
    }

    - (void)createYahooSession
    {
            // create session with consumer key, secret and application id
         // set up a new app here: https://developer.yahoo.com/dashboard/createKey.html
    // because the default values here won't work
        self.session = [YOSSession sessionWithConsumerKey:@"MYConsumer KEy" 
                                    andConsumerSecret:@"MY Secret" 
                                     andApplicationId:@"My APPID"];

        if(self.oauthResponse) {
            NSString *verifier = [self.oauthResponse valueForKey:@"oauth_verifier"];
            [self.session setVerifier:verifier];
        }

        BOOL hasSession = [self.session resumeSession];

        if(!hasSession) {
            [self.session sendUserToAuthorizationWithCallbackUrl:nil];
        } else {
            [self getUserProfile];
        }
    }

    - (void)getUserProfile
    {
    // initialize the profile request with our user.
        YOSUserRequest *userRequest = [YOSUserRequest requestWithSession:self.session];

    // get the users profile
        [userRequest fetchProfileWithDelegate:self];
    }

    - (void)requestDidFinishLoading:(YOSResponseData *)data
    {
        NSDictionary *userProfile = [[data.responseText JSONValue] objectForKey:@"profile"];
        // NSLog(@"%@",[userProfile description]);
        if(userProfile) {
            [viewController setUserProfile:userProfile];
        }
    }


    - (void)dealloc {
        [viewController release];
        [window release];
        [super dealloc];
    }


    @end  

SocialSampleViewController.m

 - (void)viewDidLoad {
        [super viewDidLoad];

        [nicknameLabel setText:@"loading..."];
    }

    - (void)setUserProfile:(NSDictionary *)data
    {
        NSString *welcomeText = [NSString stringWithFormat:@"Hey %@ %@!", 
                             [[data objectForKey:@"profile"] objectForKey:@"givenName"],
                             [[data objectForKey:@"profile"] objectForKey:@"familyName"]];

        [nicknameLabel setText:welcomeText];
    }

信息plist enter image description here

0 个答案:

没有答案