I'm using the FBAgent last modified on Jan 13th at 12:47pm. My loginviewcontroller is the FacebookAgentDelegate (I set the protocol).
Code:
//
// LoginViewController.m
// AppName
//
// Created by luis on 1/23/10.
// Copyright 2010 Mirando LLC. All rights reserved.
//
#import "LoginViewController.h"
@implementation LoginViewController
/*
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Custom initialization
}
return self;
}
*/
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
fbAgent = [[FacebookAgent alloc] initWithApiKey:@"KEY_REMOVED"
ApiSecret:@"SECRET_REMOVED"
ApiProxy:nil];
fbAgent.delegate = self;
[self updateStatus:self];
[super viewDidLoad];
}
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
#pragma mark Facebook Methods
-(IBAction)updateStatus:(id)sender{
[fbAgent publishFeedWithName:@"Testing iPhone Valentines App I'm creating"
captionText:@"How do I love thee Cheesy text"
imageurl:@"http://www.mirando-llc.com/mypic.png"
linkurl:@"http://mirando-llc.com/"
userMessagePrompt:@"Testing my iPhone App..."];
NSLog(@"Made it to update status...");
NSLog(@"==> %s",__PRETTY_FUNCTION__);
NSLog(@"logged in to facebook?: %d",[fbAgent isLoggedIn]);
}
@end
This is some awesome code here. I am really new at all of this, but have managed to get it almost working the way I need it. I would like to have it take a screen shot of the view, and upload it to face book. I have it uploading the view, but not a screenshot of other things that are in the view. hope that makes sense.
I have been using a screenshot button, to save to the camera roll, and would like to use that same type of button to send to facebook.
Hey thanks so much. I figured it out, was just using the wrong name for my image that I wanted to keep and upload. Now to submit the update to Apple and play the waiting game
OK, so here's a bug I have found. Updates the pic to an album, but if the user hasn't given the album permission, it crashes. And also, sometimes after posting an update, with pic, after having the app open for a couple of seconds, it just crashes.
Not sure where the problem is, but it may be in the way it grabs the screenshot. Going to try a few other things. One other problem is that it will sometimes crash after invoking the Facebook connect, after signing in, then hit connect. But it still sends the pic. Weird.
After February 17, Facebook seems to suddenly could not upload a picture, and with the App Store's Facebook APP can not upload pictures. Facebook App's review have complained that the pictures can not upload
With the developer account sign in Facebook, i can successfully upload a picture, and directly see the news feed.
With other ordinary account login Facebook, i can successfully upload a picture, but I can not see the news feed,
Then found in Facebook - "in Your Photos - iToyTools Photos can be seen "This album contains photos uploaded from another application. Select photos to approve or reject."
Must approve the photos then photo appear in the news feed.
Is it must "submit your application to the directory"
I am sure I found 2 bug
1, upper right corner of the dialog box is not the Close button (X), re-add FBConnect.bundle can resolve this problem.
2, if only call a function to upload pictures, there is no implementation of the [self askPermission];, the consequences can not update the status, upload pictures are in the auditing of the state.
Want to have a good approach, want to update, thank you
I'm getting an EXC_BAD_ACCESS crash when uploading an image. I've confirmed that the image data is good, since I used it with Facebook Connect as well. For the image data I do:
I have everything working fairly well in my new facebook intergrated app, thanks to this generous code. I upload the photo first (which, as has been mentioned, posts a somewhat unwanted entry to their wall about the photo itself, but it's not too bad), the actual call is just:
That way I know what the URL is for photo we just uploaded, but I avoided fql calls because I am too dumb to comprehend them... this is a bit hackish, but I doubt it will break anytime too soon.
And as you can see, that calls my publishStream method:
Code:
- (void) publishStream {
[[BusyAgent defaultAgent] makeBusy:NO];
[fbAgent publishFeedWithName:@"Boy am iSorry!"
captionText:@"Please accept this heartfelt apology note."
imageurl:@"http://renditionsdesign.com/iSorry_example.png"
linkurl:currentPhotoURL
userMessagePrompt:@"What's on your mind?"
actionLabel:@"iSorry for iPhone"
actionText:@"Available on the App Store"
actionLink:@"http://itunes.apple.com/us/app/magic-card/id290645875?mt=8"];
}
(I realize it links to a different one of my apps for now, I'll fix that link eventually)
So, everything works fine, and I'm so happy! But only on the simulator. There has been discussion about a bug in this FaceBook agent code that used NSDictionary when NSMutableDictionary is needed, but I can't seem to solve my problem by changing that.
The console log from my crashed device is:
2010-03-15 12:06:11.498 iSorry[2254:207] *** -[FacebookAgent count]: unrecognized selector sent to instance 0x11f5b0
2010-03-15 12:06:11.504 iSorry[2254:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[FacebookAgent count]: unrecognized selector sent to instance 0x11f5b0'
2010-03-15 12:06:11.508 iSorry[2254:207] Stack: (
844776241,
843056877,
844780055,
844282517,
844245696,
844679949,
844679821,
65045,
27473,
29997,
71069,
55039,
62509,
64409,
826631361,
826631235,
834292747,
834238481,
834238839,
834238839,
834238229,
834238157,
834238031,
834237937,
844528285,
844526429,
848374975,
848375147,
850798447,
850793587,
10725,
10588
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
[Switching to thread 11779]
(gdb)
I hope my code above / explanation of how to do facebook status postings "farmville style" is helpful to someone. Anybody have any idea what I need to do to make this run on an actual device?
It's definitely the call to uploadPhotoAsData that kills it, not the actual publishing of the stream or any of the little things I do during the process, I've been able to narrow it down pretty conclusively to that.
I just don't really understand the code in the FacebookAgent.m file well enough to fix it (he's a better programmer than me, that's for sure).
Also, even if I use the nifty sample project that AmanApps posted (Facebook Agent Test) it crashes in exactly the same way if I use uploadPhotoAtURL or uploadPhotoAsData. Anyone else see a bug in there that we can fix? I know there are others with variations on this same problem. Maybe I just don't understand the NSDictionary ---> NSMutableDictionary fix that was mentioned....?
Last edited by hobbyCoder; 03-15-2010 at 04:21 PM.
I'm suddenly having a bizarre problem when trying to publish a feed with facebook connect; it used to work but now when I hit my button that tells it to publish a feed, the facebook popup window comes up as usual, the activity meter spins for a second as usual...but then the activity meter disappears and the white popup just stays there forever...feed never gets published. Did something change in FB Connect recently or something? It's possible I somehow changed something to screw it up. It's worth noting that I can do a regular status update just fine. Here's some sample relevant code:
Code:
//this works
[fbAgent setStatus:[NSString stringWithFormat: @"%@", rootViewController.mainView.myLabel.text]];
//wheras this does not anymore..
[fbAgent publishFeedWithName:rootViewController.mainView.myLabel.text
captionText:@"Some Caption"
imageurl:@"http://www.myserver.com/someImage.jpg"
linkurl:@"http://www.google.com"
actionLabel:@"Please Work"
actionText:@"Damn!"
actionLink:@"http://www.google.com"];
THis is the last thing standing in my way of release...please help; thanks!