Twitter开发

摘要:
开发文档: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/enTwitter Developers community(twitter 论坛)

开发文档: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

费用问题:

Twitter开发-LMLPHP

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 AudiencesCreatives, 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开发》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇l2tp连接不上,修复剖析虚幻渲染体系(03)- 渲染机制下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

随便看看

docsify制作在线说明文档的轻量级神器

我找到了一个使用html处理和加载md文件的网站。创建一个漂亮的在线描述文档(工件docsify)非常简单,nav可以删除--˃ENChinese加载window$docsify={el:'#main',//配置节点loadSidebar:true,//设置是否加载sidebarsubMaxLevel:2,//设置最大目录级别coverpage:true;/...

db2字符串函数

可以指定可选的字符串长度单位,以指示哪些单位表示函数的起始位置和结果。使用基于字符的函数解决了将字节位置返回到字符位置的问题。代码单元16和代码单元32根据字符数计数。类似地,CODEUNITS32指定使用Unicode UTF-32来理解多字节字符的字符边界。如果使用CODEUNITS获取字符长度,则用作字符串函数输入的不同CODEUNITS将导致不同的输...

Redis设置Auth认证保护

Redis有一种保护数据安全的身份验证方法。有两种方法可以设置此身份验证。一个是通过配置文件。另一种是直接在Redis客户端命令中设置参数requirepas。首先是在配置文件中查找参数requirepass。这是配置Redis访问密码的参数。由于Redis具有很强的并发能力,并且只使用密码,攻击者可能会在短时间内发送大量密码猜测请求,这很容易被暴力破解。因...

docker.service启动失败:Unit not found的原因及解决办法

解决方案是删除/usr/lib/systemd/system/docker.service的[UNIT]中包含的dockersocket,然后重新加载systemctldaemon,最后是systemctlstartdocker.service。启动成功。在类似的情况下,docker.socket缺失,但新版本需要docker.seocket。这是因为Fla...

nginx 浏览php的时候会变成下载

php的时候会变成下载:这是因为nginx没有设置好碰到php文件时,要传递到后方的php解释器。当然啦,你的php-fpm解析器也需要正常运行,并监听好9000端口,才能最终生效并有效处理php脚本。windows下开启监听的办法,php-cgi.exe-b127.0.0.1:9000-cphpphp.ini待续:。。。。。...

[笔记]manjaro kde主题&手动安装主题

安装manjaroKDE主题。首先,安装manjaro主题,有两种方法:“系统设置”-“全局主题”-“获取新的全局主题”,您还可以在“外观”中获得“等离子样式、应用程序样式、颜色等”的新全局主题“.通过manjarokdestore下载主题,然后将主题导入系统。但是,由于某些原因,方法1在我的计算机上不可行。加载速度非常慢,下载速度非常慢。据说可以通过pro...