twitter api

1,twurl安装

1.1,安装软件管理包工具,在管理员身份打开的cmd中执行:

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString(‘https://chocolatey.org/install.ps1‘))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

1.2,choco install ruby

1.3,gem install twurl

1.4,gem install jq 格式化json

2,注册twitter开发者账号

https://developer.twitter.com/

3, 使用Restful api

3.1 获取用户最新发布(文档的Tweets下面)

Get Tweet timelines

Filter realtime Tweets standard api for free

Sample realtime Tweets


Things every developer should know

There are different API families

The standard (free) Twitter APIs consist of REST APIs and Streaming APIs.

The enterprise (paid subscription) APIs include filtered firehose, historical search and engagement APIs for deeper data analytics, listening and other enterprise business applications.

The premium (pay as you go) APIs consist of reliable and affordable versions of enterprise APIs, allowing your business to grow with your usage.

Additionally, there are some families of APIs (such as the Ads API) which require applications to be whitelisted in order to make use of them.

The API aims to be a RESTful resource

With the exception of the Streaming API and Account Activity webhooks, the Twitter API endpoints attempt to conform to the design principles of Representational State Transfer (REST). Twitter APIs use the JSON data format for responses (and in some cases, for requests).

The API is HTTP-based (over SSL)

Methods to retrieve data from the Twitter API require a GET request. Methods that submit, change or destroy data require a POST. A DELETE request is also accepted for methods that destroy data. API methods that require a particular HTTP method will return an error if not invoked using the correct style. HTTP Response Codes are meaningful.

Tweet IDs can break Javascript

Use the id_str field instead of id whenever present to stay safe. Web browsers/Javascript interpreters/JSON consumers may munge large integer-based ids, which is why it is recommended to use the string representation. See the documentation on Twitter IDs (snowflake).

There are limits to how many calls and changes can be made in a day

API usage is rate limited, with additional account-based fair use limits on write/create/delete endpoints, to protect Twitter from abuse.

Parameters have certain expectations

Some API methods take optional or requisite parameters. Keep in mind when making requests with parameters:

  • Parameter values should be converted to UTF-8 and URL encoded.
  • The page parameter begins at 1, not 0.

Where noted, some API methods will return different results based on HTTP headers sent by the client. Where the same behavior can be controlled by both a parameter and an HTTP header, the parameter will take precedence.

There are pagination limits

REST API Limit

Clients may access a theoretical maximum of 3,200 statuses via the page and count parameters for the user_timeline REST API methods. Other timeline methods have a theoretical maximum of 800 statuses. Requests for more than the limit will result in a reply with a status code of 200 and an empty result in the format requested. Twitter still maintains a database of all the Tweets sent by a user. However, to ensure performance, this limit is in place on the API calls.

There are Twitter API libraries for almost any language

The community has created numerous Twitter API libraries. If you know of others we haven’t listed, let us know via the developer forums.

原文地址:https://www.cnblogs.com/bigben0123/p/9554081.html

时间: 2024-08-13 17:52:09

twitter api的相关文章

通过调用Twitter API抓取Twitter数据

国内研究weibo的人比较多,资料也相对较多,但是twitter的资料相对较少.今天简单说一下twitter api的使用.最近一小需求,采集含有指定关键词的twitter数据,瞬间想到写个爬虫来抓取,后来突然想到twitter应该有open api可用.使用了vpn翻墙之后简单的了解了twitter.com,决定直接使用 twitter api.由于twitter的open api现在也是基于oauth协议的,因此使用流程和国内一些社区比如说人人网,weibo的api的过程类似. 要想使用tw

Twitter API 申请key

最近听了一下coursera的python课(https://www.coursera.org/learn/python-network-data/home/welcome),讲的挺简单也挺有意思.其中讲到通过twitter API爬数据的部分,因为twitter的API是需要API "Key"的,所以需要先申请一下,这个地方有点tricky. 首先,到这个网站:https://dev.twitter.com/apps, 点击creat apps 然后一步步来,把该填的填完就好. 搞定

twitter api的使用

做个项目,须要用到twitter的接口 (如果用过新浪的微博接口,会发现大同小异) 访问twitter 须要挂vpn,第一天用朋友的killwall 连上一会就断,异常不爽,然后用了'我的VPN'效果还不错  偶尔会断掉,关键是免费的,速度也不错 首先注册个账号,然后访问twitter的说明文档,接口列表,这有个中文文档有些老 但不妨碍, 英文结合这个 能明白差不多了: 我现在想要用的一个接口是statuses/home_timeline 注意这个接口须要授权 并且有调用次数的限制; 调用接口之

Twitter search API

Twitter crawler 与sina 微博类似,使用twitter api之前,首先要有twitter的账号,在twitter developer中创建应用(https://apps.twitter.com/app/new). 创建成功之后可以获得应用的信息,包括Consumer key和Consumer secret.并generate access token,将这四个数据保存下来, 接下来可以借助twitter api 进行twitter 抓取,现有的twitter api的pyth

Facebook Oauth2.0 API调用方法

这些天搞了下Facebook API的东东,在官方网站下弄了一些接口,下面简单的把facebook的调用流程以及常用接口书序一下 :-)  当然在使用facebook api之前要有facebook账号以及在facebook上注册一个自己的应用  1.登录鉴权 https://graph.facebook.com/oauth/authorize?client_id=8888888888888&redirect_uri=http://www.mywebsite.com&scope=user_

常用open api

SNS类网站API Facebook - http://developers.facebook.com/ 人人网开放平台 - http://dev.renren.com/ 51.com开放平台 - http://developers.51.com/ MySpace开发者平台 - http://developer.myspace.cn/ Opensocial - http://wiki.opensocial.org/ Google Gadgets 小工具 API 开发人员指南 - http://w

如何将twitter关联到你的magento站点 oauth1

public function post_tweet($tweet_text) { include_once('twitter/tmhOAuth.php');//tmhOAuth.php为twitter api,放到/lib/twitter下,下载地址请往下阅读 $connection = new tmhOAuth(array( 'consumer_key' => 'xrnOML0Zzk......', 'consumer_secret' => 'xFdUBpvnJ8LJHKsAx8n9GGS

Twitter数据挖掘:如何使用Python分析大数据 (3)

让我们来拉取Twitter账号@NyTimes的最近20条微博. 我们可以创建变量来存放待拉取的微博数量(即count),以及待拉取的用户(即name).然后用这两个参数调用user_timeline()函数.下面是更新后的代码(注意,在代码的顶部应该保持认证和API对象的创建). # 传入认证信息,并创建API对象 api = tweepy.API(auth) # 待拉取微博的用户 name = "nytimes" # 待拉取的微博数量 tweetCount = 20 # 使用上面的

分享前端Facebook及Twitter第三方登录

最近公司要求做海外的第三方登录:目前只做了Facebook和Twitter;国内百度到的信息太少VPN FQ百度+Google了很久终于弄好了.但是做第三方登录基本上都有个特点就是引入必须的js,设置appkey/appId;然后调用登录方法即可得到用户信息. 首先Facebook: 1).在Facebook开发者平台注册自己的application:然后得到appid和应用密钥: 2).接下来就异步引用Facebook的sdk.js并调用初始化方法: 1 window.fbAsyncInit