Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Tools & Utilities

Reply
 
LinkBack Thread Tools Display Modes
Old 01-08-2010, 11:04 PM   #26 (permalink)
Registered Member
 
scotopia's Avatar
 
Join Date: Oct 2008
Posts: 2,028
Default

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 ?

Last edited by scotopia; 01-09-2010 at 01:45 AM.
scotopia is offline   Reply With Quote
Old 01-09-2010, 06:55 AM   #27 (permalink)
Registered Member
 
kilobytedump's Avatar
 
Join Date: Oct 2008
Posts: 195
Default

Hi guys!

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?

Thanks.
kilobytedump is offline   Reply With Quote
Old 01-09-2010, 07:37 AM   #28 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
Default

@scotopia
1. AFAIK, there is no way.
2. cool finding!

Thanks a lot for identifying the bug and suggestion

@kilobytedump
yea it is possible, u need to resume the session. scotopia showed how to do this here:

http://www.iphonedevsdk.com/forum/ip...tml#post159013

happy to know it came to your help! I will appreciate if you twit or facebook share the blog link so other also might get help
AmanApps is offline   Reply With Quote
Old 01-09-2010, 07:43 AM   #29 (permalink)
Registered Member
 
kilobytedump's Avatar
 
Join Date: Oct 2008
Posts: 195
Default

Great thanks again.
kilobytedump is offline   Reply With Quote
Old 01-09-2010, 12:11 PM   #30 (permalink)
Registered Member
 
scotopia's Avatar
 
Join Date: Oct 2008
Posts: 2,028
Default

Lol; Aman the speed demon got there first again

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!
scotopia is offline   Reply With Quote
Old 01-09-2010, 01:46 PM   #31 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
Default

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

But after that I will be ready to nail 'em down!

Last edited by AmanApps; 01-09-2010 at 01:52 PM.
AmanApps is offline   Reply With Quote
Old 01-09-2010, 02:05 PM   #32 (permalink)
Registered Member
 
scotopia's Avatar
 
Join Date: Oct 2008
Posts: 2,028
Default

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'm sending you a PM right now too.
scotopia is offline   Reply With Quote
Old 01-13-2010, 09:05 AM   #33 (permalink)
indie dev
 
rocotilos's Avatar
 
Join Date: Oct 2009
Posts: 2,754
Thumbs up

Aman,

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.

Looking forward to use your twitteragent as well.

Excellent stuffs!!

Again, thanks a lot man!
rocotilos is offline   Reply With Quote
Old 01-13-2010, 10:43 AM   #34 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
Default

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;

Download from here: http://www.amanpages.com/wordpress/w...ebookAgent.zip

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.

... sharing is really fun!!! community rocks!
AmanApps is offline   Reply With Quote
Old 01-13-2010, 11:13 AM   #35 (permalink)
indie dev
 
rocotilos's Avatar
 
Join Date: Oct 2009
Posts: 2,754
Default

Hi Aman,

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"];
it crashes.

Last edited by rocotilos; 01-13-2010 at 11:37 AM.
rocotilos is offline   Reply With Quote
Old 01-13-2010, 11:39 AM   #36 (permalink)
Registered Member
 
scotopia's Avatar
 
Join Date: Oct 2008
Posts: 2,028
Default

If an album is not specified it auto creates an album with the app name; at least that's what it did for me!
scotopia is offline   Reply With Quote
Old 01-13-2010, 11:42 AM   #37 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
Default

1. no, you don't need to create an album first. It will auto create an album by the fb app name ( the fb app with the secret/api key ).


for this you can call these:
Code:
- (void) uploadPhotoAtURL:(NSString*)imageurl withCaption:(NSString*)captionOrNil toAlbum:(NSString*)aidOrNil;

or

- (void) uploadPhoto:(NSString*)imageurl;

hope this works... because i know the man who wrote this crap, he is just a dumb-***
AmanApps is offline   Reply With Quote
Old 01-13-2010, 11:43 AM   #38 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
Default

oh... sorry.. I was late..
@scotopia Thanks a lot
AmanApps is offline   Reply With Quote
Old 01-13-2010, 11:52 AM   #39 (permalink)
indie dev
 
rocotilos's Avatar
 
Join Date: Oct 2009
Posts: 2,754
Default

Ok got it to work. Thanks guys.

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)

Thanks Aman and Scotopia.
rocotilos is offline   Reply With Quote
Old 01-13-2010, 12:52 PM   #40 (permalink)
indie dev
 
rocotilos's Avatar
 
Join Date: Oct 2009
Posts: 2,754
Default

Hi again,

Code:
-(IBAction)uploadPhoto {
	//fbAgent.shouldResumeSession =YES;
	NSData* data = UIImageJPEGRepresentation(theImg.image, 1.0);
	[fbAgent uploadPhotoAsData:data withCaption:@"Some texts" toAlbum:nil];

}
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?
rocotilos is offline   Reply With Quote
Old 01-13-2010, 01:00 PM   #41 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
Default

define the following method in class where you are using fbagent.

Code:
- (void) facebookAgent:(FacebookAgent*)agent photoUploaded:(NSString*) pid{
}
AmanApps is offline   Reply With Quote
Old 01-13-2010, 01:20 PM   #42 (permalink)
indie dev
 
rocotilos's Avatar
 
Join Date: Oct 2009
Posts: 2,754
Default

Ok thanks Aman. It worked nicely.

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.
rocotilos is offline   Reply With Quote
Old 01-13-2010, 01:39 PM   #43 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
Default

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.

how to use:
Code:
// Queue busy mode
[[BusyAgent defaultAgent] makeBusy:YES];

// Dequeue busy mode
[[BusyAgent defaultAgent] makeBusy:NO];

// Force remove busy mode
[[BusyAgent] forceRemoveBusyState];
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.

Hope it may help.
AmanApps is offline   Reply With Quote
Old 01-13-2010, 01:43 PM   #44 (permalink)
indie dev
 
rocotilos's Avatar
 
Join Date: Oct 2009
Posts: 2,754
Default

Damn man, u are fast. Thanks.. will check it out..

btw, i detected a spelling error in the FBAgent of yours. (nothing big)..

- (void) askUplaoadPhotoToAlbumPermission



edit: Just tested the BusyAgent.. works like a charm. Saved me times
from doing extra work on the UI.

EXCELLENT WORK, Aman!!

Last edited by rocotilos; 01-13-2010 at 01:57 PM.
rocotilos is offline   Reply With Quote
Old 01-13-2010, 01:50 PM   #45 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
Default

Thanks a lot! fixed the typo and updated the zip (available on same download url).
AmanApps is offline   Reply With Quote
Old 01-13-2010, 02:27 PM   #46 (permalink)
indie dev
 
rocotilos's Avatar
 
Join Date: Oct 2009
Posts: 2,754
Default

Hi Aman, me again.

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)

Code:
- (id)myinit{
	if( (self = [super init])){
		busyCount = 0;
		UIWindow* keywindow = [[UIApplication sharedApplication] keyWindow];
		view = [[UIView alloc] initWithFrame:[keywindow frame]];
		view.backgroundColor = [UIColor blackColor];
		view.alpha = 0.85;
		
		wait = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
		wait.hidesWhenStopped = NO;
		wait.frame = CGRectMake(0,0,50,50);
		wait.center = view.center;
		
		busyLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 170, 320, 21)];
		busyLabel.textColor = [UIColor whiteColor];
		busyLabel.backgroundColor = [UIColor clearColor];
		busyLabel.shadowColor = [UIColor blackColor];
		busyLabel.shadowOffset = CGSizeMake(-1,-1);
		busyLabel.textAlignment = UITextAlignmentCenter;
		busyLabel.text = @"Processing Request... Please Wait";
		
		[view addSubview:wait];
		[view addSubview:busyLabel];
		[wait startAnimating];
		
		return self;
	}
	
	return nil;
}
I also changed the alpha so that the white text stand out. All are UI matters.. just sharing anyways.
rocotilos is offline   Reply With Quote
Old 01-13-2010, 03:01 PM   #47 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
Default

many many thanks for your this code! Added to the class and is available from the same url.
AmanApps is offline   Reply With Quote
Old 01-19-2010, 12:38 AM   #48 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 135
Default thanks for the code

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?
__________________
--- sup
mediashock is offline   Reply With Quote
Old 01-19-2010, 01:28 PM   #49 (permalink)
Registered Member
 
scotopia's Avatar
 
Join Date: Oct 2008
Posts: 2,028
Default

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.
scotopia is offline   Reply With Quote
Old 01-21-2010, 08:04 AM   #50 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 21
Default

removed

Last edited by eyefone; 01-21-2010 at 02:30 PM.
eyefone is offline   Reply With Quote
Reply

Bookmarks

Tags
facebook, facebook api, facebook connect

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 264
17 members and 247 guests
14DEV, @sandris, ADY, ArtieFufkin10, bookesp, ckgni, Dani77, DarkAn, HemiMG, iDifferent, jakerocheleau, JasonR, prchn4christ, Rudy, Speed, theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,767
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:49 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0