English 中文(简体)
Publish UIImageace
原标题:Publish UIImage Facebook Problems
  • 时间:2012-04-15 07:08:09
  •  标签:
  • ios
  • facebook

我试图把图像张贴到Facebook上。 昨天一开始,但今天我再次测试了它,并做了大量工作。 我无法找到问题。 我已经修改了一些内容,但没有修改Facebook与它互动的方法。 我希望有人能够帮助我。

我认为,我谈的是一切,因为只有在用户要求时,才算出。

我把它gged倒了下来,只有“出版手册”才被叫来,因为我叫它。 它涉及Facebook,要求获得许可,然后是你回去,没有发生。

URL计划是正确的。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>fb235694579858240</string>
        </array>
    </dict>
</array>
</plist>

ViewController.h

import "FBConnect.h"

@interface ViewController : UIViewController <UIImagePickerControllerDelegate, UIActionSheetDelegate, UIGestureRecognizerDelegate, MFMailComposeViewControllerDelegate, FBSessionDelegate, FBDialogDelegate, FBRequestDelegate>

@property (nonatomic, retain) Facebook *facebook;
-(void)postWall;

主计长。

-(void) publishFacebook:(UIImage *)img { 
    
    //start the facebook action by clicking any button
    _publishedImage = img;
    _facebook = [[Facebook alloc] initWithAppId:@"235694579858240" andDelegate:self];
    
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) {
        _facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
        _facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
    }
    
    if (![_facebook isSessionValid]) {
        NSArray *permissions = [[NSArray alloc] initWithObjects:
                                @"user_photos",
                                @"user_likes", 
                                @"read_stream",
                                nil];
        _facebook.sessionDelegate = self;
        [_facebook authorize:permissions];
    }else{
        [self postWall];
    }
}
    
    
    - (void)fbDidLogin {
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        [defaults setObject:[_facebook accessToken] forKey:@"FBAccessTokenKey"];
        [defaults setObject:[_facebook expirationDate] forKey:@"FBExpirationDateKey"];
        [defaults synchronize];
        [self postWall];
    }
    
    - (void)postWall{
        
        //NSString *filePath = [[NSBundle mainBundle] pathForResource:@"image" ofType:@"png"];
        NSData *imageData = UIImagePNGRepresentation(_publishedImage);
        //[NSData dataWithContentsOfFile:filePath]
        NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                       @"Check out my awesome image!. I make it with Trolling for iOS", @"message", imageData, @"source", nil];
        [_facebook requestWithGraphPath:@"me/photos" andParams:params andHttpMethod:@"POST" andDelegate:self];
        
        NSLog(@"Image posted");
        
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Image Posted" message:@"Your image was successfully posted of facebook" delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
        [alertView show];
    }
    
    -(void)fbDidNotLogin:(BOOL)cancelled{
        if (cancelled) {
            UIAlertView *alertView=[[UIAlertView alloc]initWithTitle:@"Could not Login" message:@"Facebook Cannot login please try again" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles: nil];
            [alertView show];
        }
    }


- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    return [_facebook handleOpenURL:url];
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    return [_facebook handleOpenURL:url]; 
} 

成就

最佳回答
问题回答

暂无回答




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签