Twitter - info API - twitter

How to use the twitter geo api.

Did you read the Documentation in the link you posted? It says
Requires Authentication : TRUE

Ever since the geoapi shut down, it has been pretty much integrated with the twitter api. The json returned by twitter GET statuses also returns a geo key in the dictionary and geo_enabled key as well.
Here's what you can do to authorize and receive updates via oauth and twitter api (python code)-
from twitter import Twitter
from twitter.oauth import OAuth
def get_feeds(screenName):
twitter = Twitter(auth=OAuth('', '', CONSUMER_KEY, CONSUMER_SECRET))
statuses = twitter.statuses.user_timeline(screen_name=screenName, include_entities=1, include_rts=True)
print "Got Status"
return statuses

Related

How to get followers list from Twitter?

I am trying to call following Twitter's API to get a list of followers for a user.
http://api.twitter.com/1.1/followers/ids.json?cursor=-1&screen_name=username
And I am getting this error message in response.
{
code = 215;
message = "Bad Authentication data";
}
I can't seem to find the documentation related to this error code. Anyone has any idea about this error?
Your request lacks authentication data. I got that error when I simply clicked on http://api.twitter.com/1.1/followers/ids.json?cursor=-1&screen_name=username. This is not the way to access twitter API.
Create a Twitter app from https://apps.twitter.com/. Then, try using a Twitter API Library to access REST API. If you are comfortable with using ruby apps on command line interface check out https://github.com/sferik/t. Set it up and then try t followers [USER] for listing all followers of USER.
You will have to use OAuth. More info can be found on Twitter website. Here: https://dev.twitter.com/oauth
This error is coming because your Twitter developers account is not approved. Now-a-days you can't make app without getting your developers account approved from Twitter.
To make an app, you need to contact Twitter and apply for developers account. If you are lucky engough, you will get approval although this process may take months.
If you just need the data, go for third party services like followersanalysis[dot]com, birdsonganalytics[dot]com

weibo get status of other user?

I want to get the timeline post of the other user using weibo api but not getting.weibo API. I am using few API Call like user_timeline,trends but not getting any proper data. please, let me know if I missing any API or any settings in App. I have appKey, secret key and redirect url.
As far as I can tell, the API calls that would get you this info have all been restricted. The English documentation is not updated, but the chinese documentation specifies for example that you can only use User_timeline to get your own timeline, not others.
http://open.weibo.com/wiki/2/statuses/user_timeline
接口升级后:uid与screen_name只能为当前授权用户

gdata link from Firefox doesn't work any more for YouTube API?

At least a year ago, if I go to
http://gdata.youtube.com/feeds/api/videos?v=2&max-results=1&q=intitle:"Relapse"+intitle:"Eminem"&orderby=viewCount
from FireFox browser, I could the list of video titles that meet the search query in this address.
But now it doesn't work.
Has it been deprecated?
#user3123767 The YouTube Data API (v2) has been officially deprecated as of March 4, 2014. Please refer to our deprecation policy for more information. Please use the YouTube Data API (v3) for new integrations and migrate applications still using the v2 API to the v3 API as well. Ref
All calls to Google APIs now require that you send Your Api Key, which you can obtain one from Here
Once you got your API Key You can Make various calls
For example Search for videos using the key word "Hollywood"
Run this code and see the result in console
(function($){
function SearchYouTube(queryToSearch,pageToken,ApiKey,maxResults){
var
YoutubeUrl="https://www.googleapis.com/youtube/v3/",
pageToken=pageToken,
maxResults=maxResults,
ApiKey=ApiKey,
$.get(YoutubeUrl+"search?q="+queryToSearch,{
part : 'snippet',
pageToken:pageToken,
key:ApiKey,
maxResults:maxResults
},
function(data) {
//let check if request is granted with our Api Key
if(!data.items[0]){console.log("System Configuration Error");}
//If request granted okay
var
videoId=data.items[0].id.videoId,
videoImgUrl=data.items[0].snippet.thumbnails.high.url,//medium | default | high
videoTile=data.items[0].snippet.title,
nextPageToken=data.items[0].nextPageToken;// Useful if you want the next set of datas
//Display data on page here if you want
//See console Log of results that you can use
console.log(data);//Dump data
}//Success
);
}
//Usage
SearchYouTube("Hollywood","","xxx Your Api Key xxx",5);
//==================All Closed==========
})(jQuery);
See Working Sample Here
could be a few reasons.
YouTube API v2.0 is deprecated not sure if it totally down now or not.
All calls to Google APIs now I think require that you send a at the very least a public API key. I just tested the following
http://gdata.youtube.com/feeds/api/videos?q=skateboarding+dog&start-index=21&max-results=10&v=2&key=[api
key]
It returned
This webpage is not available
I think I am going to have to say that its not working anymore you should try and use YouTube API v3 instead.

Twitter API 1.1 Oauth w/ Meteor

I'm pretty new to Meteor and a total beginner with the Twitter API. I am creating a simple application in Meteor for demonstration purposes only. I need to be able to search Twitter for a specific hashtag. I just need to be able to get the tweets using that hashtag and display them in a list. Super simple.
I've registered my app, received keys and such. I just need to see an example of the code flow from starting before Oauth to receiving the results of the Twitter search.
I will be running this app locally and just need to be able to send a GET request and receive a RESTful response.
I have seen documentation about how jQuery isn't supported due to security risks. Since my backend is JS I need to be able to do this with JS.
Can anyone suggest documentation on how I can do this where I can see code examples?
Since the v1.1 of Twitter API (may 2013), it's not possible to search without being authorized using OAuth.
If you want to do it client side in a simple way, you may want to use OAuth.io.
I've just made an example in jsfiddle to make a simple search using Twitter API
The code is quite simple:
//Initialize the SDK with my OAuth.io public key, then display the OAuth authorization form
OAuth.initialize('YOUR-PUBLIC-KEY')
OAuth.popup('twitter', function(err, twitter) {
var search = encodeURIComponent("#oauth.io")
twitter.get('/1.1/search/tweets.json?q=' + search)
.done(function(data) {
console.log(data); //your search results are in data
})
})
Good question. You are correct, the Twitter 1.1 API requires oAuth tokens even for simple GET requests like the one you need. Yeah, requesting an oAuth key and secret from the twitter dev site can seem like overkill for a locally running project, but it's required for every one of their API endpoints.
Once you have the oAuth consumer key and secret, you are all set to make your API calls. Casual googling on the twitter dev site suggests that sending oAuth creds via JQuery is not supported by Twitter for security reasons. You can read more about that here.
I am not sure what you need to do with the Twitter data, so I'm not embedding any code samples for oAuth. In the mean time, check out how oAuth works as you think about how to implement your solution. PHP? Python? Ruby? Perhaps these oAuth code samples from Twitter are a good place to start?
There is a meteorite library intended to get around this exact problem.
https://github.com/subhog/meteor-twit
You can follow the documentation for use:
https://github.com/ttezel/twit
Below is some example code:
if (Meteor.isServer) {
Meteor.methods({
twit_get: function() {
Twit = new TwitMaker({
consumer_key: 'foo',
consumer_secret: 'foo',
access_token: 'foo',
access_token_secret: 'foo'
});
Twit.get(
'search/tweets',
{
q: 'banana since:2013-12-11',
count: 10
},
function(err, reply) {
console.log(reply);
});
}
});
}

Why is the access token that I pass to appEngine from iOS invalid?

I am working on an iPhone game that maintains a leaderboard and some social interaction through a backend that I built in Google App Engine. The user can log in through facebook in the iPhone app. The app sends some user details including the access token to my Google App Engine app through an HTTP post.
The handler that receives the request tries to use the access token to retrieve the users friends. I am using the pythonforfacebook SDK (which I have had success with previously) which is on Github here:
https://github.com/pythonforfacebook/facebook-sdk
The relevant python code in my GAE app is as follows:
def post(self):
at = self.request.get('at')
user = User.get_by_key_name(uid)
if not user: #create previously unknown user
logging.info('Entered unknown user code')
logging.info(at)
logging.info(type(at))
graph = facebook.GraphAPI(at)
facebook_user = graph.get_object("me")
friends = graph.get_connections(facebook_user["id"], "friends")
The logging commands print what looks like a good access token and states that the type is 'Unicode'. When I copy the access token that logging.info prints to the GAE logs and paste it into the facebook access token debugger, I get the following output:
App ID: deleted for privacy but looks right
Metadata: {"sso":"iphone-safari"}
User ID: deleted for privacy but looks right
Issued: 1345405177 (10 minutes ago)
Expires: Never
Valid: True
Origin: Mobile Web Faceweb
Scopes: offline_access read_stream
I just updated my code to use the most recent posted version of pythonforfacebook but that didn't make any difference. Any ideas would be much appreciated.
Thanks,
Dessie
To get friends of the user you can do it pretty easily without the pythonforfacebook SDK.
https://graph.facebook.com/<username or ID>/friends?access_token=<your token>
That link will give you the friends of the user in JSON format. So if you import urllib2 and json you could do:
response = urllib2.urlopen(<url above>)
friendsString = response.read()
friends = json.loads(friendsString )
Then friends will be a dict containing of all the friends.

Resources