Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

Commit

Permalink
Update to v2 API
Browse files Browse the repository at this point in the history
  • Loading branch information
andypiper committed Aug 26, 2020
1 parent 1a3fc29 commit c07452b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Program.cs
Expand Up @@ -26,7 +26,7 @@ static void Main(string[] args)

// this is the endpoint we will be calling
StringBuilder apiPath = new StringBuilder("https://api.twitter.com");
apiPath.Append("/labs/2/tweets");
apiPath.Append("/2/tweets");
apiPath.AppendFormat("?ids={0}", tweetID);
apiPath.Append("&tweet.fields=attachments,author_id,context_annotations,created_at,entities,geo,id,in_reply_to_user_id,lang,possibly_sensitive,public_metrics,referenced_tweets,source,text,withheld");
apiPath.Append("&media.fields=duration_ms,height,media_key,preview_image_url,type,url,width");
Expand Down
8 changes: 3 additions & 5 deletions README.md
@@ -1,10 +1,10 @@
# TwitterDotNetCore

[![license](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://github.com/andypiper/TwitterDotNetCore/blob/master/LICENSE) [![Labs v2](https://img.shields.io/static/v1?label=Twitter%20API&message=Developer%20Labs%20v2&color=794BC4&style=flat&logo=Twitter)](https://developer.twitter.com/en/docs/labs/overview/versioning) [![Twitter Follow](https://badgen.net/twitter/follow/andypiper)](https://twitter.com/intent/follow?screen_name=andypiper)
[![license](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://github.com/andypiper/TwitterDotNetCore/blob/master/LICENSE) [![v2](https://img.shields.io/endpoint?url=https%3A%2F%2Ftwbadges.glitch.me%2Fbadges%2Fv2)](https://developer.twitter.com/en/docs/twitter-api/early-access) [![Twitter Follow](https://badgen.net/twitter/follow/andypiper)](https://twitter.com/intent/follow?screen_name=andypiper)

A simple sample app using DotNet Core and the new Twitter API.

By default, the code prompts for a Tweet ID and then *fully hydrates* that via the [Twitter Developer Labs](https://t.co/labs) API. You may also enter a comma-separated list of IDs, as the API endpoint will also handle multiple IDs (up to 100).
By default, the code prompts for a Tweet ID and then *fully hydrates* that via the [Twitter API v2](https://developer.twitter.com/en/docs/twitter-api/early-access). You may also enter a comma-separated list of IDs, as the API endpoint will also handle multiple IDs (up to 100).

To have the code request @jack's first Tweet (Tweet ID 20), and the same fields that are returned in API v1.1, comment out the `REQUEST_URL` value in `Program.cs` and uncomment the replacement in the next section.

Expand All @@ -13,9 +13,7 @@ Hydrating a Tweet means getting all available fields for a Tweet, given a Tweet

## Directions

[Apply for a Twitter Developer Account](https://t.co.apply-for-access), and create an app. Generate access token and access token secret via the Twitter Developer Dashboard.

(optional) If using the [Twitter Developer Labs](https://t.co/labs) endpoint - as this sample does - you'll also need to have access to Labs, and to connect your app to the Tweets and Users endpoints.
[Apply for a Twitter Developer Account](https://t.co.apply-for-access), and create a Project and an App. Generate access token and access token secret via the Twitter Developer Dashboard.

Install [DotNet Core](https://dotnet.microsoft.com/download) :-)

Expand Down

0 comments on commit c07452b

Please sign in to comment.