I got it working extremely close to what I need; just have a few questions.
1. When the image gets uploaded it automatically goes to the feed as well; so with that and the deliberate feed post it is a "double whammy" that might be annoying; is there anyway to make the image upload go ninja style; so that it doesn't trigger a feed post?
2. Is there anyway to make it so the user is not prompted to insert some text before the feed publish? I tried setting the userPrompt field to nil but it just seemed to default it to "what's on your mind" with the the text area still there. I'm reading the docs now but its confusing: I think some auto_publish bool must be set to true somewhere and the app must have "extended permission"
Edit: I figured this one out: the "preview" value must be set to 0 in the feedDialogue; for some reason permissions didn't need to to be asked for publish stream; weird...
Also one suggestion: on the photo upload methods you have one of the parameters is captionOrNil; this is a little misleading as a nil causes a crash; perhaps a captionOrEmptyString ?
Thanks this fantastic work. I've literally implemented Facebook Connect in 10 minutes!
One question for the two of you.
Can I save login details? i.e. can I save logins so the user doesn't see the login screen. At the moment the user needs to input the password every time the app restarts (not for every post, just every app restart). Is this correct or am I doing something wrong?
And yes I agree; now that these functions have been added this is definitely the best facebook connect implementation around; well done!
On that point; you mentioned something about a twitter implementation; is it better then the MGTwitterWhatever one thats around? I was thinking maybe we can work one where sending and image to twitpic along with the post to twitter is an option; so that would kill too birds with one stone?
Right now I have a rough twipic/twitter posting method that works; but no nice login flow for the user; just hardcoding my twitter username and password as a test. If we can nail down twitter/twitpic as well; we'd have the ultimate package for social networking apps!
hey, scotopia! I was also thinking somehow same! I also think it will be a great tool to develop app faster and easier.
About twitter implementation, now it has quiet streamlined flow since but not completely standalone yet.
But, it is NOT openauth based. I've used nsurlconnection and handled the authentication, then posted the twit. So, it would be best if openauth could be implemented.
Have u used open auth?
Right now suddenly I got tremendous weekend work pressure. Won't be able to work on this for next 3 days I afraid
Sounds good; I believe the MGTwitterEngine thing used oAuth; I'll look it over again; I remember it being a bit cumbersome. Maybe send me or post what you have with some commenting detailing what you'd like changed or added and I can try to fill in the blanks? I know if you want to post to twitpic that will take care of the twitter post as well; but as yet my twitpic method has no authorization or anything; its just a barebones test:
Code:
NSURL *url = [NSURL URLWithString:@"http://twitpic.com/api/uploadAndPost"];
NSString *username = @"myUsername";
NSString *password = @"myPassword";
NSString *message = @"This is a test!";
NSData *twitpicImage = myAppDelegate.currentScreenshot;
// Now, set up the post data:
ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease];
[request setData:twitpicImage forKey:@"media"];
[request setPostValue:message forKey:@"message"];
[request setPostValue:username forKey:@"username"];
[request setPostValue:password forKey:@"password"];
// Initiate the WebService request
[request start];
[self viewWillDisappear:YES];
Using ASIFormDataRequest for the form post stuff (this might not be necessary later).
I just tested your latest fbAgent in my app.
It is so damn easy to implement. I cant thank you enough.
However, I have few noob questions:
1. How to upload image from UIImageView instead of the URL image?
2. Does the agent check whether the feed post is done successfully or not?
If it does, then how to check for it? Im thinking of giving an alert after the publish is successful/not.
hi rocotilos! Nice to know that it came into your help, Pleasure is mine
1. you have to upload to an album.
use uploadPhotoAsData. ucan get the data by using UIImagePNGRepresentation.
Actually, in the background, first data is fetched from any image url and uploaded as NSData.
2. Nice idea, i just added handler if request like status or image upload is failed.
Added a required method to the interface:
- (void) facebookAgent: (FacebookAgent*)agent dialog: (FBDialog*)dialog didFailWithError: (NSError*)error;
But still, these are not well tested actually hardly tested. I faced some problem setting status today:
"Error(102) Session key invalid or no longer valid"
no idea ...
I would appreciated if you share (m)any bug found and also solve or suggestion to that.
1. So does that mean in my fb, i have to have an album first? Can the fbAgent auto create an album? Sorry, im a noob in this, and in fb as well.
Can i just post photos/image to the wall instead?
edit: i see that the toAlbum parameter of the method UploadPhotoAsData is NSString. is this where we put the name of the album in fb as NSString? I created the album in fb already with a name "Test", but when i call this code:
Code:
[fbAgent uploadPhotoAsData:data withCaption:@"What do you think? - Image created with XXXX" toAlbum:@"Test"];
Before this it was not working, i think we cannot be LOGGED IN in Safari (at Mac)
while testing the fbAgent. I need to logout first, then i run the app and post the photo
thru the app.
And just found out another thing, is that, if your app is running in the simulator, and then you login in Safari (at Mac), after a while the app crashes too.
Can u try this and replicate my results?
(but i think there is not problem, since the app is running on actual device and there is no way for Safari in device to run simultaneously with the app)
This is my code to upload to the default application album.
After i tap the button, this method gets called and the fbconnect window show up (since i commented out the resume code). after login, then it disappears. after that there is no message for the app, whether it is successfully uploaded, or not. Is there are method to detect whether the app is successfully uploaded the image?
Just that am thinking on the user's experience side. won't it be weird that there is no message to inform the app user whether the app successfully upload or photo, or not?
Previously it seems not working well, because I used a big-*** image (~400kb in size) when testing. And my internet is super snail speed.
To others who is using this:
When implementing this agent into your app, it is probably wise to hide the uploadphoto button after pressing it, and upon completion of upload (by delegate method photoUploaded) make the button visible again. and while waiting the photo to be uploaded, maybe also put a timeout, in case after a while the internet connection is lost.. or something.
thanks rocotilos for the suggestion. btw, I have created another agent to help in this situation.. this new recruit is named BusyAgent and can be downloaded from here.
Use:
BusyAgent ads a translucent view and a UIActivityMonitor to avoid tapping on any other items. So, call this just before you call fbagent or other agent function or anywhere you need.
I tweaked a bit the BusyAgent. (added a text only). in this method:
in BusyAgent.m (.h for UILabel declaration and the release part for busyLabel in dealloc)
I was trying to implement facebook connect and i got it working but only 50% of the time it would upload the photo.. is there something wrong with fb connect?
so then i tried fbAgent and i am having same 50% upload problem... sometimes it upload and sometimes it does not.. anyone has an idea what it could be? also in fbAgent do i have to ask for permission or is that done in the backround?
I am seeing this behavior as well; it appears like there is a 3 second timeout or something; and if the image hasn't been uploaded in time the request fails...trying to figure out how to change it.