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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-12-2010, 05:01 AM   #1 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
AmanApps is on a distinguished road
Thumbs up Twit with TwitterAgent : One line code, auto tineURL

Hello all,

Perhaps you have seen my post on FacebookAgent class which simplifies facebook integration into your iPhone app.

Now, I would like the share my TwitterAgent class with you.
Using this class you can integrate twitter into your app in a single line of code!
Code:
[[TwitterAgent defaultAgent] twit ];

[[TwitterAgent defaultAgent] twit:@"Search with google!" ];

[[TwitterAgent defaultAgent] twit:@"Search with google!" withLink:@"http://www.google.com" makeTiny:NO];

[[TwitterAgent defaultAgent] twit:@"Search with google!" withLink:@"http://www.google.com" makeTiny:YES];
Read more and Download the code from here.

Some screenshots:







Any feedback and suggestion is highly appreciated.

Last edited by AmanApps; 01-12-2010 at 10:36 AM.
AmanApps is offline   Reply With Quote
Old 01-12-2010, 12:41 PM   #2 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 4
dissonance is on a distinguished road
Default

i'll definitely give it a try!
dissonance is offline   Reply With Quote
Old 01-12-2010, 01:09 PM   #3 (permalink)
Registered Member
 
scotopia's Avatar
 
Join Date: Oct 2008
Posts: 2,070
scotopia is on a distinguished road
Default

Nice work again Aman; I notice the custom login...does this not go through oAuth?
scotopia is offline   Reply With Quote
Old 01-12-2010, 01:17 PM   #4 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
AmanApps is on a distinguished road
Default

@dissonance: let me know if you have any suggestion

@scotopia, hey, Thanks! nope, its not open auth.
I was looking for you, could you manage time on using open auth with iphone? I was totally lost in the open auth section on twitter site...
AmanApps is offline   Reply With Quote
Old 01-12-2010, 02:00 PM   #5 (permalink)
Registered Member
 
scotopia's Avatar
 
Join Date: Oct 2008
Posts: 2,070
scotopia is on a distinguished road
Default

Yeah I got oAuth working with regular twitter updates; unfortunately image services like twitpic, yfrog etc don't do oAuth with their API so i've had to fall back on basic auth for those. Basically I just modified ben gottlieb's engine here: bengottlieb's Twitter-OAuth-iPhone at master - GitHub
scotopia is offline   Reply With Quote
Old 01-12-2010, 02:14 PM   #6 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 96
alon7 is on a distinguished road
Default

Thank you !!!
I really needed this!

can you post a sample app that show how to use it?

It doesn't work for me.

Thanks again.
alon7 is offline   Reply With Quote
Old 01-12-2010, 02:32 PM   #7 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
AmanApps is on a distinguished road
Default

@alon7:
When you add the folders to your project, you have to select 'copy' instead of reference. It worked with me anyway.. here is sample project. What I have done here:
1. Created a new project.
2. from xcode added the TwitterAgent and the BusyAgent folders to the project. Selected copy.
3. added a button to the view.
4. added a touch event inside handler for the button.
5. in the handler code, i used the twitter agent.

btw, don't forget to import TwitterAgent.h where you want to use this.

Let me know if still any prob.


@scotopia: cool man! Thanks for sharing the link
AmanApps is offline   Reply With Quote
Old 01-12-2010, 02:37 PM   #8 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 96
alon7 is on a distinguished road
Default

Thanks, worked for me.
alon7 is offline   Reply With Quote
Old 01-12-2010, 03:15 PM   #9 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 96
alon7 is on a distinguished road
Default

Another problem popped up.

I have a tableview and a didSelectRowAtIndexPath method.

When I'm pressing the cell its shows a alertview the asks cancel or facebook.

If I press facebook, nothing happens.
(Of course it have the facebook code: [fbAgent setStatus:@"status from iPhone demo"]; )

Where is the problem?

I tried to make a new view and put it in the viewDidLoad method and it didn't work either.

Seems like it's only working with UIButton.

Any suggestions?

Thanks.
alon7 is offline   Reply With Quote
Old 01-12-2010, 11:49 PM   #10 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
AmanApps is on a distinguished road
Default

hi Alon7,
Sorry man, I also faced the same problem for some reason it doesn't work on viewDidLoad..

If you find out any solution, please share. I will also look into it. Currently working on creating another tool.
Thanks.
AmanApps is offline   Reply With Quote
Old 01-20-2010, 08:20 AM   #11 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 11
zxl777 is on a distinguished road
Default

FacebookAgent and TwitterAgent are very cool,
Is very easy to use, packaged very well.
Thank you for sharing such a good code, so that Facebook and Twitter's programming has become so relaxed and happy.

Very much hope that TwitterAgent can easily upload Image, hope to see even better updates, Thanks again.

Last edited by zxl777; 01-20-2010 at 08:24 AM.
zxl777 is offline   Reply With Quote
Old 01-23-2010, 05:46 AM   #12 (permalink)
Registered Member
 
Join Date: Dec 2009
Location: Mumbai
Posts: 45
hardikapatel is on a distinguished road
Send a message via MSN to hardikapatel Send a message via Yahoo to hardikapatel Send a message via Skype™ to hardikapatel
Default

here is the another link from where you can download twitter application.Not developed by me but I can help you if you want.

Koh Jing Yu
__________________
Thanks & Regards
Hardik.A.Patel.
hardikapatel is offline   Reply With Quote
Old 03-16-2010, 03:21 PM   #13 (permalink)
Registered Member
 
Join Date: Sep 2008
Posts: 99
hobbyCoder is on a distinguished road
Default

Wow, I'm getting better... I found a bug, and I fixed it! (I love this wrapper class, by the way.)

In line 401 of TwitterAgent.m it should read:

NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"http://tinyurl.com/api-create.php?url=%@",link]];

The percent sign was missing, and that broke it. You'd get Tiny URLs, but they didn't go anywhere, because it was generating TinyURLs for the link "@" instead of what was intended.

Now, could someone find that one other bug in the Facebook agent for me, that was the limit of my brain power!
hobbyCoder is offline   Reply With Quote
Old 04-02-2010, 04:06 AM   #14 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
AmanApps is on a distinguished road
Default

Thanks for the fix

please check iphone-facebook-twitter-connect-easy-integration-tool - Project Hosting on Google Code
AmanApps is offline   Reply With Quote
Old 04-19-2010, 07:18 PM   #15 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 40
Bitzal is on a distinguished road
Default

[[TwitterAgent defaultAgent] twit:@"%@", barObj.barName];

Too many arguments to function twit.
Am i missing something here? No doubt I am! Thank for help if you can
Bitzal is offline   Reply With Quote
Old 04-21-2010, 02:33 AM   #16 (permalink)
Registered Member
 
Join Date: Aug 2009
Posts: 12
jonahgrant is on a distinguished road
Default

Quote:
Originally Posted by Bitzal View Post
[[TwitterAgent defaultAgent] twit:@"%@", barObj.barName];

Too many arguments to function twit.
Am i missing something here? No doubt I am! Thank for help if you can
Code:
[[TwitterAgent defaultAgent] twit:[NSString stringWithFormat:@"%@", barObj.barName]];
jonahgrant is offline   Reply With Quote
Old 04-21-2010, 02:40 AM   #17 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 2
johnmite123 is on a distinguished road
Default

It is good that we can tweet with the twitter agent, I will appreciate if you twit or facebook share the blog link so other also might get help...
johnmite123 is offline   Reply With Quote
Old 04-21-2010, 04:04 AM   #18 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 92
funkyspider is on a distinguished road
Default

I really like your popup dialogs, similar to BiteSMS txt input dialog. I may be 'liberating' that code.


I'd suggest implementing xAuth authentication, which in my opinion is better that oAuth as you can control user/pass input and token management yourself.

Like OAuth xAuth uses a one-off token exchange when the user authorises you app at first use.

xAuth requires you to contact twitter (via email) and perform registration of your app. Twitter posts then say 'from myApp'. Twitter took around a day to respond to my request and authorise my app for xAuth. Until authorised you just get a network error (401 ?) if you try and connect using xAuth.


There is a xAuth framework written and published under MIT license

blogg : Aral Balkan xAuthTwitterEngine library and demo
code : aral's XAuthTwitterEngine at master - GitHub

This framework is itself made up of MGTwitter etc, so I'm sure the author would have no issues with incorporating the authentication section into your own framework - assuming the code was published under the same open license.

I implemented twitter using this xAuth framework and must say it works really well. I used keychain to store the exchanged token, and provided a way to log out which simply deletes the token from the keychain - next access see's there's no token and requests login/authentication again.

Last edited by funkyspider; 04-21-2010 at 04:06 AM.
funkyspider is offline   Reply With Quote
Old 04-21-2010, 04:11 AM   #19 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
AmanApps is on a distinguished road
Default

@funkyspider

Thanks A LOT for the links! I will integrate oAuth asap since its the ultimate way!
AmanApps is offline   Reply With Quote
Old 04-21-2010, 04:34 AM   #20 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 92
funkyspider is on a distinguished road
Default

xAuth - you have to register app with twitter and request xAuth access (via email - link on that blogg page) and control your own login view.

OAuth - handles the login for you if the app hasn't been authorised. You do not have to register your app with twitter via Email. This is the OAuth login page which is automatically displayed.
http://blog.trapster.com/wp-content/...tter-oauth.png


An oAuth framework also exists under MIT license.
bengottlieb's Twitter-OAuth-iPhone at master - GitHub

I added similar text to my xAuth login form -

"app requesting access to read and post to twitter. You may revoke access at any time by visiting your settings page in twitter"


To store the xAuth exchange token in the phones keychain is a pain, but again there is a framework which simplifies it massively.
Sci-Fi Hi-Fi: Weblog: Simple iPhone Keychain Code
security at master from ldandersen's scifihifi-iphone - GitHub

Code:
+ (NSString *) getPasswordForUsername: (NSString *) username andServiceName: (NSString *) serviceName error: (NSError **) error;
+ (void) storeUsername: (NSString *) username andPassword: (NSString *) password forServiceName: (NSString *) serviceName updateExisting: (BOOL) updateExisting error: (NSError **) error;
+ (void) deleteItemForUsername: (NSString *) username andServiceName: (NSString *) serviceName error: (NSError **) error;
Using xAuth/oAuth all you actually store is the single token value which is given to you when the user authorises.

As you are only storing a token value which has been returned from you can hard code the username as 'twituser', the serviceName as 'twitter' etc when using the getPasswordForUsername/ storeUsername / deleteItemForUsername methods. The token is then just stored as the password.
funkyspider is offline   Reply With Quote
Old 04-21-2010, 05:59 AM   #21 (permalink)
Scan Me !
 
MozyMac's Avatar
 
Join Date: Nov 2009
Posts: 608
MozyMac is on a distinguished road
Send a message via AIM to MozyMac Send a message via MSN to MozyMac Send a message via Yahoo to MozyMac
Default

OMG DUDE, You are a live saver, I'm trying your facebook code as well, hope it's as awesome and easy as this!
MozyMac is offline   Reply With Quote
Old 04-21-2010, 06:22 AM   #22 (permalink)
Scan Me !
 
MozyMac's Avatar
 
Join Date: Nov 2009
Posts: 608
MozyMac is on a distinguished road
Send a message via AIM to MozyMac Send a message via MSN to MozyMac Send a message via Yahoo to MozyMac
Default

any chance that you could update the code to add remember me (password and username) feature ?

Thank you.
MozyMac is offline   Reply With Quote
Old 04-21-2010, 06:39 AM   #23 (permalink)
iPhone Developer, PlayDom
 
AmanApps's Avatar
 
Join Date: Jul 2009
Posts: 61
AmanApps is on a distinguished road
Default

@mozymac: It was not saved due to a bug. Just before fixed it and committed.
Please check out from the google code or from my blog.

thanks

@funkyspider: cool, just one prob is that users have to leave the application to let safari open. thanks.
AmanApps is offline   Reply With Quote
Old 05-15-2010, 08:28 AM   #24 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 8
kumar74 is on a distinguished road
Default

can you upload or email me your code for Twitter using Xauth? It will really be a great help. Thanks in Advance.

Kumar
kumarSG201@gmail.com

Quote:
Originally Posted by funkyspider View Post
I really like your popup dialogs, similar to BiteSMS txt input dialog. I may be 'liberating' that code.


I'd suggest implementing xAuth authentication, which in my opinion is better that oAuth as you can control user/pass input and token management yourself.

Like OAuth xAuth uses a one-off token exchange when the user authorises you app at first use.

xAuth requires you to contact twitter (via email) and perform registration of your app. Twitter posts then say 'from myApp'. Twitter took around a day to respond to my request and authorise my app for xAuth. Until authorised you just get a network error (401 ?) if you try and connect using xAuth.


There is a xAuth framework written and published under MIT license

blogg : Aral Balkan xAuthTwitterEngine library and demo
code : aral's XAuthTwitterEngine at master - GitHub

This framework is itself made up of MGTwitter etc, so I'm sure the author would have no issues with incorporating the authentication section into your own framework - assuming the code was published under the same open license.

I implemented twitter using this xAuth framework and must say it works really well. I used keychain to store the exchanged token, and provided a way to log out which simply deletes the token from the keychain - next access see's there's no token and requests login/authentication again.
kumar74 is offline   Reply With Quote
Old 05-27-2010, 05:26 AM   #25 (permalink)
Registered Member
 
suksmo's Avatar
 
Join Date: Mar 2010
Location: iTunes store : Scrambleface otherwise Scotland
Posts: 262
suksmo is on a distinguished road
Default

Hi it all works fine for me apart for when I want to pass in my own values as below - I get the error message 'too many arguments to function twit' - does anyone know how to sort this - thanks

-(IBAction) response1 {
NSInteger row = [singlePicker selectedRowInComponent:0];
NSString *selected = [pickerData objectAtIndex:row];

[[TwitterAgent defaultAgent] twit:@"%@!", selected];
}
__________________
FREE live action video puzzler

download it FREE now:-
http://itunes.apple.com/us/app/scram...416999968?mt=8
suksmo is offline   Reply With Quote
Reply

Bookmarks

Tags
tinyurl, twitter

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: 326
12 members and 314 guests
2Apps1Day, akacaj, Domele, Duncan C, GraffitiCircus, michelle, NetGuru, NSString, Paul Slocum, Sloshmonster, soohyun, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,650
Threads: 94,114
Posts: 402,886
Top Poster: BrianSlick (7,990)
Welcome to our newest member, soohyun
Powered by vBadvanced CMPS v3.1.0

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