How to integrate location information into Twitter app? - iphone

I'm trying to get a Twitter iPhone app working using Matt Gemmell's MGTwitterEngine. I can post tweets OK, but I can't work out how to attach location data to those tweets... anyone have any idea?

I've never used MGTwitterEngine but from looking at the code, it should be as simple as calling sendUpdate:withLatitude:longitude:. What have you tried? What did and what did not work? Please be more specific.

There is no way to do post tweets with location information with MGTwitterEngine as of now. I am currently working on bringing the library up to date. You can check github.com/freeatnet/MGTwitterEngine/tree/v2-dev for updates. I'll be pushing a commit containing a method for geo-aware updates today.
UPD. See commit # http://github.com/freeatnet/MGTwitterEngine/commit/512be99cca9f5787192633455300dcd788c7830c for location-aware updates.
Method signatures:
(NSString *)sendUpdate:(NSString *)status;
(NSString *)sendUpdate:(NSString *)status fromLocationLat:(float)locLat locationLong:(float)locLong;
(NSString *)sendUpdate:(NSString *)status inReplyTo:(unsigned long long)updateID fromLocationLat:(float)locLat locationLong:(float)locLong;

Related

How do I open a user's Twitter profile using the Twitter app using a link in Mobile Safari?

It looks like Twitter registers the URI scheme of twitter://, but after playing around with it I can't get it to directly open a user's profile. I've tried:
twitter://username
twitter://user/username
twitter://profile/username
with no luck. I'll need it to work on Android as well.
Thoughts?
I found two URL schemes for twitter tweetie:// and twitter://:
tweetie:///user?screen_name=jessicaalba
twitter:///user?screen_name=jessicaalba
On this wiki site you can find a lot of other iphone url schemes (including twitter)
Doesn't seem to be official documented anywhere so I wouldn't count on all versions of the Twitter app supporting it but http://groups.google.com/group/twitter-development-talk/browse_thread/thread/92b958b7af002993?pli=1 gives a hint that might be worth a try:
I just found that "twitter:///user?screen_name=tvdw" works as well.
I know you are looking specifically to open it up with the official Twitter app but what if the person doesn't have the app, then the functionality will not work in your app.
Why not just use MGTwitterEngine in this case since it will work for everyone and it will remain in your app?
For those wondering how to test if the scheme executes:
- (BOOL)openURL:(NSString *)url
- (void) clickTwitter {
if (![self openURL:#"twitter:///user?screen_name=mufumbo"]) {
if (![self openURL:#"tweetie:///user?screen_name=mufumbo"]) {
[self openURL:#"http://twitter.com/mufumbo"];
}
}
}
you can include many more and make it a generic loop.

Twitter API for iPhone?

I want to integrate my app with twitter. I need to show tweets containing certain hashtags or from a particular user.
I tried MGTwitterEngine+xOAuth, but i want twitter tweets only so no need of authentication required. MGTwitterEngine+xOAuth needs authentication so any API or method to get tweets certain hashtags or from a particular user.
you are right, you don't neeed xOAth to make a search according to twitter search API.
If you want to use MGTwitterEngine you can use one of those methods :
// Search method
- (NSString *)getSearchResultsForQuery:(NSString *)query;
- (NSString *)getSearchResultsForQuery:(NSString *)query sinceID:(MGTwitterEngineID)sinceID startingAtPage:(int)pageNum count:(int)count; // search
- (NSString *)getSearchResultsForQuery:(NSString *)query sinceID:(MGTwitterEngineID)sinceID startingAtPage:(int)pageNum count:(int)count geocode:(NSString *)geocode;
You can find more details in MGTwitterEngine.h. It seems that you don't have to set authentification parameters to make a search, you just have to create an engine :
twitterEngine = [[MGTwitterEngine alloc] initWithDelegate:self];
You can use MGTwitterEngine with search api or you can call twitter search API directly. The problems with search API is that you can only get tweets up to 14 days old. It can be as easy as: http://search.twitter.com/search.json?q=%23hello

Follow on Twitter using MGTwitterEngine iphone

I am using MGTwitterEngine for integrate Twitter on my iPhone application. so i want to follow a particular person using this library. can any one suggest me how i do this.
Thanks
I have not try to follow a user ..
Let try this metthod
-(NSString *)enableUpdatesFor:(NSString *)username
and let me know

Using retweeted_by API with MGTwitterEngine - keeps on returning error 404

I'm trying to add a method to MGTwitterEngine to use twitter's retweeted_by API ( http://dev.twitter.com/doc/get/statuses/:id/retweeted_by ).
Here is what I've added to MGTwitterEngine.m (all the OAuth stuff is done, the other methods inside the engine work fine)
-(NSString *)getUsersWhoRetweetedTweetWithID:(unsigned long)ID {
NSString *path = [NSString stringWithFormat:#"statuses/70482402362933249/retweeted_by.xml"];
return [self _sendRequestWithMethod:nil path:path queryParameters:nil body:nil
requestType:MGTwitterUsers
responseType:MGTwitterUsers];
}
Note: I've already included the .xml format and a status ID - just to ensure there's nothing wrong with the data I'm passing on. When I call [_engine getUsersWhoRetweetedTweetWithID:0]; from my app controller, error 404 is returned "The operation couldn't be completed. (HTTP error 404.)".
I've tried it with a parameters NSDictionary & tried changing the request & response types.
Currently, I don't make use of MGTwitterEngine to check who RTd a tweet, I just use a non OAuth'd method - however this will not return protected users who RTd a tweet.
Can anyone give me a point in the right direction - it's being driving me crazy for the past few days! I really appreciate any input :)
Take a look here.....
How to do a RETWEET on an iPhone twitter app (MGTwitterEngine)
MGTwitterEngine does not support re-tweet method yet .. you have to manually add the parse to MGTwitterEngine .h and .m then the call out would be [_engine sendRetweet:(unsigned Long)];
Now I am in the process of trying to determine how you call out the unsigned long...if any one else has an answer to that I would be happy to hear it myself.

MGTwitterEngine getting feeds - iPhone

So, in my app, I am trying to use MGTwitterEngine to read from a certain user on Twitter, and then log the recent posts in an array. Is it possible to do this with this library? I am trying to do this without logging in. Any help would be appreciate, thank you!
It can be easily done with MGTwitterEngine. You do it this way:
MGTwitterEngine *twitterng = [[MGTwitterEngine alloc] initWithDelegate:self];
[twitterng getUserTimelineFor:#"userName" sinceID:0 startingAtPage:0 count:8];
and it will call delegate method
- (void)statusesReceived:(NSArray *)statuses forRequest:(NSString *)connectionIdentifier
Hope this helps.
You need to get the feed url that contains the rss feeds. You don't need to login for that. Use MGTwitterEngine to get the tweets and set them into array. Then you simply need to reload the tableview.
Hope this helps.
Thanks,
Madhup