开发文档:https://developer.twitter.com/

the Twitter Developer Account Application 示例:https://wptweetboost.com/example-of-the-twitter-developer-account-application-process/

Help Center:https://help.twitter.com/en

Twitter Developers community(twitter 论坛):https://twittercommunity.com/

身份认证:https://developer.twitter.com/en/docs/basics/authentication/overview/3-legged-oauth

TwitterOAuth:https://twitteroauth.com/

  The most popular PHP library for use with the Twitter OAuth REST API.

步骤:

  1.申请a Twitter developer account:developer.twitter.com

  2.创建Twitter Apps:https://apps.twitter.com/

原文:

As of July 2018, you must apply for a Twitter developer account and be approved before you may create new apps. Once approved, you will be able to create new apps from developer.twitter.com.

For the near future, you can continue to manage existing apps here on apps.twitter.com. However, we will soon retire this site and consolidate all developer tools, API access, and app management within the developer portal at developer.twitter.com. You will be able to access and manage existing apps through that portal when we retire this site.

Get started with Twitter APIs and tools:https://developer.twitter.com/en/apply-for-access.html

  All new developers must apply for a developer account to access Twitter APIs. Once approved, you can begin to use our standard APIs and our new premium APIs.

More about restricted uses of the Twitter APIs:https://developer.twitter.com/en/developer-terms/more-on-restricted-use-cases

费用问题:

1. Create a Twitter app.

    • Create a Twitter app with an approved developer account from the developer portal. If you are creating the app on behalf of your company, it is recommended you create the app with a corporate Twitter account. To apply for a developer account, click here.
    • Enable “Read, Write and Access direct messages” on the permissions tab of your app page.
    • On the "Keys and Access Tokens" tab, take note of your app's Consumer Key (API Key) and Consumer Token (API Secret).
    • On the same tab, generate your app's Access Token and Access Token Secret. You will need these Access Tokens to register your webhook URL, which is where Twitter will send account events.
    • If you are unfamiliar with Twitter Sign-in and how user contexts work with the Twitter API review Obtaining Access Tokens. As you add accounts for which to receive events, you will subscribe them using that account's access tokens.
    • Take note of your app's numeric ID, as seen in the "Apps" page of the developer portal. When you apply for Account Activity API access, you'll need this app ID.

2. Get Account Activity API access

After creating a Twitter app, the next step is applying for Account Activity API access.

Premium

To access the Sandbox or Paid Premium Account Activity API tiers, you
need to set up a developer account. If you have not applied for a
developer account yet, please do so at the following link:

Once you have a developer account, then you are ready to set up
your access to the Premium Account Activity API. You will need a
registered

  1. Login and navigate to the "Dev Environments" page.
  2. Click 'Set up dev environment,' name your environment, and specify a Twitter app ID for the environment. The environment name you chose will replace the :env_name
    token in our example premium endpoint URLs. For example, if you use the
    'prod' environment name, your URL pattern would be 
    https://api.twitter.com/1.1/account_activity/all/prod/webhooks.

Enterprise

Those needing enterprise level access to more than 250 account
subscriptions and 3+ webhooks will need to submit an application at the
following link:

Apply for Enterprise acce

3. Develop webhook consumer app

Once you have received Account Activity API access, you need to develop, deploy and host a web app that will receive Twitter webhook events.

  • Create a web app with a URL to use as your webhook to receive events. This is the endpoint deployed on your server to listen for incoming Twitter webhook events.

    • The URI path is completely up to you. This example would be valid: https://mydomain.com/service/listen
    • If you are listening for webhooks from a variety of sources, a common pattern is: https://mydomain.com/webhook/twitter
    • Note that the specified URL can not include a port specification (https://mydomain.com:5000/NoWorkie).
  • As described in our Securing Webhooks guide,
    a first step is writing code that receives a Twitter Challenge Response
    Check (CRC) GET request and responds with a properly formatted JSON
    response.
  • Register your webhook URL. You will make a POST request to a /webhooks.json?url= endpoint.
    When you make this request Twitter will issue a CRC request to your web
    app. When a webhook is successfully registered, the response will
    include a webhook id. This webhook id is needed later when making some requests to the Account Activity API.
  • Twitter will send account webhook events to the URL you registered.
    Make sure your web app supports POST requests for incoming events. These
    events will be encoded in JSON. See HERE for example webhook JSON payloads.
  • Once your web app is ready, the next step is adding accounts to
    receive activities for. When adding (or deleting) accounts you will make
    POST requests referencing the account id. See our guide on adding subscriptions for more information.

4. Validate setup

  • To validate your app and webhook are configured correctly, favorite a
    Tweet posted by one of the Twitter accounts your app is subscribed to.
    You should receive a favorite_events via a POST request to your webhook URL for each Favorite your subscribers receive.

中文资料:

  如何在Twitter开发者平台上注册自己的应用

  瞎折腾之Webhooks

  twitter APi的使用与twitter数据的应用

  Twitter API中文文档

  

英文资料

  Twitter Apps

  ads api application

  twitter engineering

  twitter marketing

  Stay up-to-date with Twitter developer platform news

  understanding-discourse-trust-levels

  Programmatically create and manage Twitter Ads campaigns.

  
 
 

  Sorting

  API reference index

  products-overview

  Twitter Ads API

  advertiser api forums:https://twittercommunity.com/c/advertiser-api

  Tutorials:Instructions and examples to help you get started

  Twitter Dev in github

    https://github.com/twitterdev

  data-ads-sample

  twitter-python-ads-sdk

  twitter-ruby-ads-sdk

  TwitterKitSample

  analytics-tag-check

  Twitter libraries

    LinqToTwitter

      LinqToTwitter

    Spring.NET Social extension for Twitter

    tweetinvi

      We are in the process of verifying the compatibility of the library with the Twitter Ads API.

    Crafted.Twitter

  Libraries built for HTTP with OAuth that should also work with Twitter

    .NET

    • DotNetOpenAuthby Andrew Arnott — an OpenID, OAuth and InfoCard library
    • hammock2 by @danielcrenna — an HTTP API client supporting OAuth authentication.
    • Spring.NET Socialby @SpringForNet — Spring.NET REST Client extension supporting OAuth authentication (docs) (examples)

  Libraries built for the Twitter Platform

.NET

    • LINQ2Twitter by @joemayo (examples)
    • Spring.NET Social extension for Twitter by SpringSource — A Spring.NET Social extension with connection support and an API binding for Twitter.
    • TweetSharp by @danielcrenna — A .net library for Twitter API access
    • Tweetinvi maintained by Linvi — a Twitter .Net C# API which has for mission to simplify the development of application for Twitter in C#. The streaming API has been used on research projects and collected around 3.2 million Tweets a day. The Twitter API has been created to be easy to implement new functionality and currently provide access to most of the functionalities. (documentation)
    • Crafted.Twitter by @martbrow — A caching compatible solution - with implementations for both ASP.Net Web Forms and MVC. Making it easy to include Tweets in your website.

  Advertise on the Twitter network

Twitter’s Ads API endpoints provide developers a programmatic way to create and manage Twitter Ads campaigns. In addition, these endpoints provide a means to access features like Audiences, Creatives, Targeting, etc. Our tutorials page contains all the necessary information around the Ads entity hierarchy as well as a basic getting started guide.

Apply for Ads API access

In order to be able to use any of the Ads API endpoints, first create a Twitter app and apply for access here. Feel free to play around in our sandbox environment as well.

Check out our SDKs

The Python and Ruby SDKs provide a frictionless means to integrate with the Ads API directly in your application.

If you’re an expert on the Ads API feel free to help out others as well! Questions? See our developer forums.

  Tweet objects

  Introduction to Tweet JSON

  

工具:

  Using Twurl

  

Tweets

  Post, retrieve and engage with Tweets

  timezones

  Rate Limiting

  Tweet objects

  

  

获取TwitterAPI keys
• 注册一个Twitter账号
• 到https://apps.twitter.com/登入twitter账号
• 点击“Create New App”,新建你自己的应用
• 填写应用信息表单, 然后点击“Create your Twitter application”生成你的twitter应用
• 在“keys and Access Tokens”界面, 点击“API keys”, 然后记录你的“API key” 和"API secret".
• 在“keys and Access Tokens”界面点击“Create my access token”, 记录你的"Access token" and "Access token secret".
这里我就不啰嗦一步一步截图了,按照上面一步一步做就行。但是只里面有一个坑,需要注意的:twitter在创建应用时,你的twitter账号一定要绑定你的手机,但是国内的手机运营商收不到验证码。这里好像可以用手机版twitter去绑定手机号(实测联通可以收到验证码,电信好像不可以,移动没试过)

使用TwitterAPI
这里我使用的twitter4J来调用twitter接口。
Twitter4j:http://twitter4j.org/en/index.html
在这里你下载twitter4j的zip包然后解压,将lib下面的这些jar包导入你的项目中。

twitter4j-core-source.jar包是自己打包的源码包,用来查看函数源码。
注:twitter4j的文档写的很不全,参考意义不是很大,你可以结合下载zip包中的examples文件夹中的例子还可以看twitter官网的Twitter REST APIs:https://dev.twitter.com/rest/public
twitter4j是的使用需要FQ代理,还有当你设置好以后,有可能会碰到链接拒绝(看你用的什么代理),因为eclipse默认走的是ipv6协议,具体解决方法可以参考我这篇文章:
http://blog.csdn.net/u013817676/article/details/51906754

Application not approved

  1. Is possibile to know when applications that already exist will be definitively killed if not approved?

  2. Isn’t possible to submit a new request of approval correcting what was wrong?

  3. is it possible to get a direct contact to someone who manage it to understand what is wrong in a specific application?

  1. We are not killing off any apps. You can read more about recent changes that we made related to this inbound here: Keeping things safe - new requirements affecting developers 58

  2. At this point in time, it is not possible to submit a new request.

  3. I am your direct contact at this point in time. Please review our policies 30 to better understand how your use case doesn’t fit.

If you have created a Twitter app via the apps.twitter.com platform before July 24th, then you will be able to manage that Twitter app via apps.twitter.com for the foreseeable future. If you have applied for a new developer account, you will also be able to edit manage that Twitter app via the developer portal as well. Since July 24th, you are required to have an approved developer account to create new apps.

If you are using one of the POST endpoints (Tweet, Retweet, Favorite, DM, Follow), you are currently rate limited based on the user level. On October 22nd (announcement about the delay), there will be new App level rate limits applied to those endpoints. These POST rate limits will be applied to all Twitter apps, regardless of when they were created.

Initial Setup

As a developer, there are several steps that you will need to take in order to begin using the Direct Messages services.

Step 1 - Create a Twitter app.

  • Create an app on the "Apps" page of your approved developer account. If you are creating the app on behalf of your company, it is recommended you create the app with a corporate Twitter account.
  • Enable “Read, Write and Access direct messages” on the permissions tab of your app page.
  • On the "Keys and Tokens" tab, take note of your app's Consumer Key (API Key) and Consumer Token (API Secret).
  • On the same tab, generate your app's Access Token and Access Token Secret. You will need these Access Tokens to register your webhook URL, which is where Twitter will send account events.
  • If you are unfamiliar with Twitter Sign-in and how user contexts work with the Twitter API review Obtaining Access Tokens. As you add accounts for which to receive events, you will subscribe them using that account's access tokens.
  • Take note of your app's numeric ID, as seen in the "Apps" page of the developer portal. When you apply for Account Activity API access, you'll need this app ID.

Step 2 - Get access to Account Activity API

After creating a Twitter app, the next step is applying for Account Activity API access.

Premium

To access the Sandbox or Paid Premium Account Activity API tiers, you need to set up a developer account. If you have not applied for a developer account yet, please do so at the following link:

Apply for developer account

Once you have a developer account, then you are ready to set up
your access to the Premium Account Activity API. You will need a Twitter
app to attach to your Account Activity API dev environment.

  1. Login and navigate to the Dev Environments page.
  2. Click 'Set up dev environment,' name your environment, and specify a Twitter app ID for the environment. The environment name you chose will replace the :env_name
    token in our example premium endpoint URLs. For example, if you use the
    'prod' environment name, your URL pattern would be 
    https://api.twitter.com/1.1/account_activity/all/prod/webhooks.

Step 3 - Develop webhook consumer app

If you would like to use a script with a visual dashboard to get set
up with your account activities, you should check out the Twitter
Dev-supported Account Activity Dashboard.

  • Once you have received Account Activity API access, you need to
    develop, deploy and host a web app that will receive Twitter webhook
    events.
  • Create a web app with a URL to use as your webhook to receive
    events. This is the endpoint deployed on your server to listen for
    incoming Twitter webhook events.

    • The URI path is completely up to you. This example would be valid: https://mydomain.com/service/listen
    • If you are listening for webhooks from a variety of sources, a common pattern is: https://mydomain.com/webhook/twitter
    • Note that the specified URL can not include a port specification (https://mydomain.com:5000/NoWorkie).
  • As described in our Securing Webhooks guide,
    a first step is writing code that receives a Twitter Challenge Response
    Check (CRC) GET request and responds with a properly formatted JSON
    response.
  • Register your webhook URL. You will make a POST request to
    a /webhooks.json?url= endpoint. When you make this request Twitter will
    issue a CRC request to your web app. When a webhook is successfully
    registered, the response will include a webhook id. This webhook id is
    needed later when making some requests to the Account Activity API.
  • Twitter will send account webhook events to the URL you registered.
    Make sure your web app supports POST requests for incoming events. These
    events will be encoded in JSON. See HERE for example webhook JSON payloads.
  • Once your web app is ready, the next step is adding accounts to
    receive activities for. When adding (or deleting) accounts you will make
    POST requests referencing the account id. See our guide on adding subscriptions for more information.
  • To validate your app and webhook are configured correctly, favorite a
    Tweet posted by one of the Twitter accounts your app is subscribed to.
    You should receive a Favorite event via a POST request to your webhook
    URL for each Favorite your subscribers receive.

Step 4 - Obtain User Permission

In order to perform write actions (create Tweets or messages) on
behalf of another account or to read private information from that
account, you will need to obtain access tokens. Access tokens provide
the user context when using the Twitter API.

Basic Definitions

  • User - A Twitter @user. All write actions on the Twitter API require
    the context of a user. Chatbots exist on Twitter accounts and are not
    their own entity. The account the chatbot exists on is a user. Customers
    interacting with the chatbot are also users. All messages sent on
    Twitter are between two user entities.
  • App - A Twitter app is created in your approved developer account. An app is always owned by a single user. The app provides the base context for using the Twitter API.

How are tokens generated? Two scenarios:

  1. User owns the app / Single User - If the user is the owner of the
    app, they can generate access tokens on the “Keys and Tokens” tab in an
    app's "Details" section within the from the "Apps" page in the developer portal. Click the “Create” button on the bottom of the page.
  2. User does not own the app / Multiple Users - If your app is going to
    consume Account Activity events on behalf of multiple users, each user
    must authenticate with your app to grant permission. To achieve this you
    must have a web app that implements Twitter Sign-in.

At this point in the process, you should have all of the necessary information to set up an application in the developer portal,
perform the initial Challenge Response Check to secure your endpoint,
and obtain access tokens in order to publish content on both your own
application and on behalf of others who have given explicit permission.
Now let's take a look at the different endpoints we will be using in our
app.

Step 5 - Understanding how the endpoints fit together

To make experiences conversational we provide Direct Message data in
real time via webhooks which includes metadata about the features in
that experience. Additionally, we have REST endpoints to create
messages, get welcome messages and custom profile data, and manage these
features. Understanding the basic flow below will help you set up your
own app based on the sampleapp you cloned in step 3.

Direct Messages

Welcome Messages

Subscription Endpoints

Debugging Tools

Below is a list of debugging tools you may find useful when building your application:

    • Postman - Build mock requests
    • Ngrok - Test the code on your local machine
    • Runscope - Enables a developer to see how the flow of the API works

Twitter开发的更多相关文章

  1. Twitter开发2

    There are different API families The standard (free) Twitter APIs consist of REST APIs and Streaming ...

  2. twitter接口开发

    前一阵子研究了下twitter接口,发现网上的资料不是很多.遂花了些心血,终于有所收获~ 现在有时间赶紧整理出来便于自己以后查阅,也想帮助有困难的同学们.废话不多说,现在就以最简洁的方式开始了.注意: ...

  3. iOS:iOS开发非常全的三方库、插件等等

    iOS开发非常全的三方库.插件等等 github排名:https://github.com/trending, github搜索:https://github.com/search. 此文章转自git ...

  4. mui开发webapp(2)

    前端开发APP,从HBuilder开始~ 序 通过 HTML5 开发移动App 时,会发现HTML5 很多能力不具备.为弥补HTML5 能力的不足,在W3C 中国的指导下成立了www.HTML5Plu ...

  5. 思考 ”前端开发人员都在关注的 GitHub 资源“

    点这里 原文: 资源 免费的计算机编程类中文书籍 免费编程书籍 计算机科学论文 codeparkshare Python初学者书籍.视频.资料.社区推荐 Python资料汇总 app应用推荐 码农周刊 ...

  6. iOS开发--完整项目

    完整项目 Phonetic Swift 写的一个 iOS 版的 Phonetic Contacts,功能很多,其中昵称功能非常实用,已在 GitHub 开源并上架 App Store v2ex – v ...

  7. 跨平台移动APP开发进阶(二)HTML5+、mui开发移动app教程

    前端开发APP,从HBuilder开始~ 序 通过 HTML5 开发移动App 时,会发现HTML5 很多能力不具备.为弥补HTML5 能力的不足,在W3C 中国的指导下成立了www.HTML5Plu ...

  8. iOS开发之资料收集

    github排名:https://github.com/trending, github搜索:https://github.com/search. 此文章转自github:https://github ...

  9. AngularJS + CoffeeScript 前端开发环境配置详解

    AngularJS 号称 '第一框架' ('The first framework') 确实是名不虚传.由其从jQuery中完全转入AngularJS后就有无法离开他的感觉了.虽然AngularJS的 ...

随机推荐

  1. https://scrapingclub.com/exercise/detail_cookie/

    def parse(self, response): pattern=re.compile('token=(.*?);') token=pattern.findall( response.header ...

  2. Spring tokenizeToStringArray

    tokenizeToStringArray: StringUtils.tokenizeToStringArray(pattern, this.pathSeparator, this.trimToken ...

  3. 使用yaml+groovy实现Java代码可配置化

    背景与目标 在使用函数接口和枚举实现配置式编程(Java与Scala实现),使用了函数接口和枚举实现了配置式编程.读者可先阅读此文,再来阅读本文. 有时,需要将一些业务逻辑,使用配置化的方式抽离出来, ...

  4. 直流-直流(DC-DC)变换电路_BUCK&BOOST变换电路

    1. 直流—直流变换器通过对电力电子器件的通断控制,将直流电压断续地加到负载上,通过改变占空比改变输出电压平均值. BUCK线路原理图如上,其中Q管/MOS作为开关管,驱动电压一般为PWM. 当开关管 ...

  5. 移动端点击返回时强制页面刷新解决办法(pageshow)

    在做移动端项目的时候经常遇到这样一个功能比如: 返回后页面不刷新,一些失效的信息依然显示在页面上.这个问题在iphone手机上会出现,在Android手机上返回时会自动刷新(由于手机机器种类不多,无法 ...

  6. 微信小程序制作家庭记账本之四

    第四天,仍然对记账本代码进行研究,对按钮的大小设置,颜色,具体位置进行分析,但其中很多代码都不明白.

  7. [转载]SQL Server中的事务与锁

    了解事务和锁 事务:保持逻辑数据一致性与可恢复性,必不可少的利器. 锁:多用户访问同一数据库资源时,对访问的先后次序权限管理的一种机制,没有他事务或许将会一塌糊涂,不能保证数据的安全正确读写. 死锁: ...

  8. Compare AURO OtoSys IM100 with OtoSys IM600

    The main difference lies in Mercedes-Benz, VW, Audi software and adapters to work with. Software dif ...

  9. MyEclipse与Eclipse配置清单

    MyEclipse与Eclipse配置清单 1.编码设置    workspace -> 设置全局编码utf-8    修改JSP编码(Encoding)为UTF-82.Java配置    格式 ...

  10. 关于Eclipse新建Dynamic Web Projecj默认未创建web.xml的问题

    当使用eclipse新建Dynamic Web Projecj时,由于J2EE技术规范的更新,当使用Dynamic web module version默认版本为3.0时,将默认不会创建web.xml ...