Twitter API - iOS - ios

I am currently creating an iOS app that integrates Twitter in such a way that it loads tweets into a UITableView. Currently I have gotten the tweets to load into the table view but I am having some issues with the names of the tweeters.
I can get the ID of the users. For example 1186989888 is the ID for DummyCode
Is there a way I can get from the ID, 1186989888 and have it return "Dummy Code". Which is DummyCode's screen name.
Does anyone know if this is possible with the Twitter API and iOS?

The Twitter users/lookup endpoint allows lookup by user_id, for up to 100 users at a time.
For a web-friendly view, you can also look up a single user by ID using a intent/user URL, e.g.
https://twitter.com/intent/user?user_id=1186989888

Related

is there an API to get all of an Instagram business account's posts that include a particular hashtag?

I am trying to get media with an hashtag that is specific to a particular user. Instead, the api seems to provide all the public images with the hashtags that is not specific to the account.
This is the api to get media nodes using hashtag that I tried:
{hashtag-id}/recent_media?user_id={iguserId}&fields=id,media_type,comments_count,like_count,caption
This one returns the public images associated with that particular hashtag in addition to the account's media that I need. For example:
I am requesting for images in a user's account that has #xxxx as hashtag. I am expecting the account's images alone containing xxxx tag. However, in the response I am receiving images from other accounts as well which has the same #xxxx hashtag. This api seems to work globally and I don't understand the use of 'user_id' parameter in the api.
Check out this API. Very simple to use and you can get media from a hashtag and specify an account. This will help you get all of an Instagram business account's posts.
Python 3.x Implementation:
import instaloader
# Get instance
L = instaloader.Instaloader()
#Load the UserName
profile = instaloader.Profile.from_username(L.context, USERNAME)
#Read the profile posts and downloads those containing the hashtags
for i in profile.get_posts():
if HASHTAG in i.caption_hashtags:
L.download_post(i, target=DIRECTORY_NAME)

Twitter Phirehose - Getting a user stream of user other than the logged in user

$sc = new FilterTrackConsumer(OAUTH_TOKEN, OAUTH_SECRET, Phirehose::METHOD_FILTER);
$sc->setTrack(getTrackKeywords());
$sc->consume();
returns tweets that contain certain keywords, from any users.
$sc = new MyUserConsumer(OAUTH_TOKEN, OAUTH_SECRET);
$sc->consume();
returns tweets by the authorized (logged-in) user.
How do I get a stream that returns tweets tweeted by a specific user-- a user other than the one logged in / oauthed?
I think I found it.
$sc->setFollow(array(
1234, 5678, 901234573 //The user IDs of the twitter accounts to follow. All of
//these users must have given your app permission.
));
If you just want the public tweets of a set of users, take a look at the example/filter-track.php code that comes with Phirehose, but use setFollow() instead of setTrack(). The parameter to setFollow() is a list of Twitter IDs (Important: you have to convert screen names to twitter IDs yourself, first). More on that here: https://dev.twitter.com/docs/streaming-apis/parameters#follow
Note: Those users do not need to have given you permission: you are just seeing what they are showing to the world.
If you want to get all Twitter activity from a bunch of users then you need to use Twitter's Site Stream API. See example/sitestream.php in the Phirehose files for that. (I was the one who wrote that example, but I have never been able to test it: Site stream has been in closed beta since the Dawn Of Time, and it is so "closed" they even ignore our requests for a developer test account!)
The middle ground is the User Streams API. This allows you to get all Twitter activity but for just one user. If you can get each user to not just permission your app, but also give you their secret keys, you could run multiple Phirehose instances, one per user, and amalgamate all the data in a central database. This would be the poor-man's Site Streams :-)

Rails - Twitter API: how to get from ID link to Twitter profile?

From the Twitter API I obtain user's ID (of course beside profile link, username etc). How can I display the link to user's profile according his ID?
For example, Facebook API provide user's ID as well, and if I put to the browser www.facebook.com/users_id, I'll get his profile...
Is there any way to do with Twitter? www.twitter.com/users_id returns empty page...
EDIT: obviously I can save user's URL (or his username), but the respective user can whenever change it...
what do you call a twitter "profile" ? I guess you talk about the user timeline
according to the api doc, your url should probably look like this :
https://api.twitter.com/1/statuses/user_timeline.html?&user_id=(your_id_here)
however, i would advise to use one of the twitter api gems to ease your pain...

Inviting *all* your friends to the Facebook Application

At the moment, using the requests dialogue I can get a multi-friend selector come up when I want the user to invite their friends to my application (that's when the "to" parameter isn't defined). On Chrome / Safari - this is a new window, but is there any way of having all of the users friends already selected?
Otherwise - is there a way to put together a request / invite to all of the users friends? I've tried getting an array of all the user's friends id's into the "to" parameter, but that gives an error on FB.
I've seen a few applications on facebook that do make it possible for the user to "select all" or "invite all" of their friends - http://blog.fbsocialapps.com/2011/10/5-ways-to-tune-your-requests-to-improve-the-virality-of-your-facebook-application/
Edit - As mentioned in the comments, I'm doing this on RoR using the omniauth gem + JS SDK. I was hoping that someone may have come across this problem, and can share a solution. My intentions are not to spam, but make it easier for the user to share the application if it's worth sharing.
Basically what the apps mentioned on the site you posted are doing is to use a custom friend selector (See also: Requests Pro-Tips, Pro-Tip 2: Create a Custom Multi-Friend Selector).
This is pretty easy and straight-forward – read the list of the users friends, generate the kind of HTML you’d like them to be displayed with (a Form, an UL, IMG elements with the friends profile picture, Checkboxes to select friends, …). If you don’t want to use the JS SDK, you can do that (reading friends list + generate the HTML) server-side as well in your RoR app.
Only the part where the user can select all friends at once is probably best done client-side – loop through all the HTML elements representing the listed friends, and check the checkboxes via script. Pretty easy if you are for example using jQuery or something.
(Of course this could also be done by just having a checkbox labeled “send request to all friends”, and see if this is checked server-side and then send request to all friends – but that would not provide direct feedback that all friends are selected now to the user on the page.)
Then you could just send the form with all/some friends marked in it to your server-side app, generate the URL for the request dialog there and put the friend’s ids into the toparameter, and redirect the user’s browser to it.

Link to a Twitter profile using the internal ID rather than the screen name

In my application I have the internal integer ID of a Twitter user and I want to provide a link to their Twitter page, e.g. I have an ID of 123456 for the Twitter account http://twitter.com/thisisanexample and I want to provide a link that resolves to the Twitter account page using the ID.
I know I could query Twitter's web services using the ID and get the screen name but I'd rather not if possible.
Does anyone know if Twitter provides a URL that takes the internal integer ID of the user and redirects to the normal user Twitter profile?
Update: No longer works
Yes. Example:
http://twitter.com/account/redirect_by_id?id=783214

Resources