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

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...

Related

Param user_id is not a valid Instagram User ID for HTTP GET

I am using the Instagram API and I'm having some small roadblocks. I already got my Access Token working on the Graph API but the user_id I'm feeding it seems to not be working, I'm retrieving the ID from Otzberg using the app-linked Instagram account's username, but I'm not sure it's the right one.
Here's the query:
https://graph.facebook.com/ig_hashtag_search?user_id={USER_ID}&q={HASHTAG}&access_token={ACCESS_TOKEN}
Any advice?
You had get legacy instagram user id from Otzberg. This user id had work with old instagram API. When you call your endpoint with this user id you should get message : Param user_id is not a valid Instagram User ID .
For use ig_hashtag_search you should get permission for Instagram Public Content Access
You should use IG User#id with this endpoint. You can search user id from business-discovery(GET /{ig-user-id}/business_discovery).
P.S. new ig-user-id - usually it 17+/- numbers.
On a browser on which you are authenticated on the good account go the page : https://graph.instagram.com/me?fields=id,username&access_token=YOUR_ACCESS_TOKEN

how to get facebook user id or user name with email id

I am developing a MVC project where I am trying to get the user id or user name from the facebook by using the email id provided by the user,
actually i want to fetch the photo of the user, which can be done using
graph.facebook.com/user_id|user_name/picture
where as i have only have the user email id.
with a little surfing on net i found that user name or user id can be fetched by using
graph.facebook.com/search?q=emailAddress&type=user&access_token=ACCESSTOKEN
but i was not able to get the access_token.
Also referred
developer facebook page
and also this
Any help or direction to work will help indeed.
Basically i understand that i need a access token to get the details.
So how do i do this in my MVC application
As you can read in the Search API docs, you can only search for Users by name, but not by E-Mail. It may have been possible in the past, but it is definitely not possible anymore.
Also, for searching by name, you need to use a User Access Token. You only get one by authorizing a User: https://developers.facebook.com/docs/facebook-login

Get twitter and google+ profile images?

I'm integrating my site with OAuth to facebook, twitter and google+
I can get the facebook profile url, but I'm unable to get any images using the provider Id's im getting back from the dotnetoauth providers.
Twitter
provider user id: 126031206
provider user name: RogerAlsing
Google+
https://www.google.com/accounts/o8/id?id=somecode-alongercode
provider user name: my email
I've seen a few working examples, but they seem to use other IDs than I get here.
Is it possible to get the profile images using any of the above values?
This looks like the OpenID method of authenticating yourself to Google, and not the OAuth2 method that they currently suggest. (And if I'm reading correctly, it looks like an older OpenID method, even.)
Current best practice for Google+ authentication to get profile information is documented at https://developers.google.com/+/web/people/ and https://developers.google.com/+/web/signin/
In particular, for an authenticated user (https://developers.google.com/+/web/signin/), you can make a people.get API call, using the special keyword "me" instead of an ID. This will return the profile picture as part of a Person resource, including other profile information, as well as the Google+ ID. Also, to understand your Google+ ID, the proper link would be https://plus.google.com/u/0/ID/posts which is the link to your Google+ profile.

Getting Facebook Public Profile URLs

I'm building a feature in my web service to let people enter their Facebook URL into a field. Because few people know their FB user names or public profile URLs, I'd like to provide an interface to assist.
In brief: is there a way to get a list of matching users's public URLs by providing a name alone?
I have tried examining the Facebook Open Graph API; this appears to require knowing the user ID of the person, or the user ID.
I have tried using Mechanize and Nokogiri to automate the process, logging into Facebook as myself and accessing the search feature (http://facebooks.com/search/results.php?q=Person%20Name), but it's not returning any data when attempted this way. I suspect Facebook is using some kind of joojoo to keep me out that way.
Anyone have any suggestions?
With a valid access token, you should be able to query https://graph.facebook.com/me/ to get their ID, name, and public URL (Here's an example using the Graph API Explorer).
There's a search endpoint in the graph API, unfortunately it requires valid user access token.
https://graph.facebook.com/search?q=<name>&type=user&access_token=<user access token>
However it could be yours even, by getting a long living access token it would work for 60 at most, but it's probably a bad idea.
The type could be user, post, event, group, page.
Having done additional research, it appears to not be possible to get a user's public profile page without their permission. Hooray for Facebook privacy settings, I guess.
However, getting an access token is easier than I imagined it would be. Facebook offers an example on their site for getting user permission to access their account, implemented entirely on the client side. Nice and easy; the access token is returned in the URL.
The only downside here is you have to create an application on Facebook, at http://developers.facebook.com/apps. For my purposes, the "Website with Facebook Login" was the application type.
From that point, you can use that token to interrogate the Graph API with ease, as both Warpling and complex857 have suggested.

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