1

私が試している間、FBLoginViewが機能していません。ボタンをクリックしても、ボタンには何の反応もありません。これは私が使用したコードです:

#import <FacebookSDK/FacebookSDK.h>
@interface myaccount ()<FBLoginViewDelegate>


- (void)viewDidLoad
{
FBLoginView *loginview =[[FBLoginView alloc] init];
loginview.frame = btn1.frame;
for (id obj in loginview.subviews)
{
    if ([obj isKindOfClass:[UIButton class]])
    {
        btn1 =  obj;
        [btn1 setBackgroundColor:UIColorFromRGB(0x3b5999)];
        [btn1 sizeToFit];
    }

}
loginview.delegate = self;
[scrol addSubview:loginview];
- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
                        user:(id<FBGraphUser>)user 
{
logu.name = [NSString stringWithFormat:@"%@!", user.first_name];
logu.profilePic.profileID = user.id;
profilePicker.profileID = user.id;
self.loggedInUser = user;
}
}

整理するのを手伝ってください。

4

1 に答える 1

0
  • Graph Api を使用して、アプリケーションに facebook を実装できます。

  • Graph api のオブジェクトを作成し、NSString *client_id = @"124262614407976"; のようにパーミッションを設定します。

    if(到達可能性フラグ==TRUE) {

    @try {
        self.fbGraph = [[FbGraph alloc] initWithFbClientID:client_id];
    
      [self.fbGraph authenticateUserWithCallbackObject:self 
         andSelector:@selector(fbGraphCallback:)   andExtendedPermissions:@"user_photos,user_videos,
    

    publish_stream,offline_access,user_checkins, friends_checkins" andSuperView:self.window];

    }
    

    @catch (NSException *例外) {

    // NSLog(@"Net not available %@",exception.userInfo); } @最後に {

    }

    }

-- コールバックを確認した後。- (void)fbGraphCallback:(id)送信者 {

if ( (fbGraph.accessToken == nil) || ([fbGraph.accessToken length] == 0) ) {

NSLog(@"You pressed the 'cancel' or 'Dont Allow' button, you are NOT logged  into   Facebook...I require you to be logged in & approve access before you can do anything useful....");

    //restart the authentication process.....
    [fbGraph authenticateUserWithCallbackObject:self andSelector:@selector(fbGraphCallback:)
                         andExtendedPermissions:@"user_photos,user_videos,publish_stream,offline_access,user_checkins,friends_checkins"];

} else
{

   // NSLog(@"------------>CONGRATULATIONS<------------, You're logged into Facebook...  Your oAuth token is:  %@", fbGraph.accessToken);

}

}

//////// フレンドフィードを見つけることができます..

-(void)getMeFeedButtonPressed{

if(delegate.fbGraph.accessToken!=nil)
{
    NSString *customString=[NSString stringWithFormat:@"me"];
    NSLog(@"here responce is for %@",customString);

    FbGraphResponse *fb_graph_response = [delegate.fbGraph doGraphGet:customString withGetVars:nil];
    NSLog(@"getMeFeedButtonPressed:  %@", fb_graph_response.htmlResponse);



    //parse our json
    SBJSON *parser = [[SBJSON alloc] init];
    NSDictionary *facebook_response = [parser objectWithString:fb_graph_response.htmlResponse error:nil];
    //  [facebook_response ]
    [parser release];
   // MyID=[facebook_response objectForKey:@"id"] ;
    [MyID appendString:[facebook_response objectForKey:@"id"]];
    NSLog(@"name  %@",[facebook_response objectForKey:@"name"]);


    NSString * url = [NSString stringWithFormat:@"https://graph.facebook.com/%@/picture",MyID];

    NSData * data = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]];

    UIImage *downloadedImage = [UIImage imageWithData:data];
    NSData *myEncodedImages = [NSKeyedArchiver archivedDataWithRootObject:downloadedImage];
    [[NSUserDefaults standardUserDefaults ] setObject:myEncodedImages forKey:@"MYFBIMAGE"];


    [self postData];


}else
{

    @try {

            [delegate.fbGraph authenticateUserWithCallbackObject:self andSelector:@selector(fbGraphCallback:)
                                 andExtendedPermissions:@"user_photos,user_videos,publish_stream,offline_access,user_checkins,friends_checkins,email"];

        }
        @catch (NSException *exception) {

            NSLog(@"Net not available");
        }
        @finally {

        }
}


}
于 2013-02-21T07:17:55.260 に答える