| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
Working Java code samples for the X (formerly Twitter) API v2.
java --versionUsing Maven, add to your pom.xml:
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.1</version>
</dependency>
</dependencies>For read-only operations (search, lookup):
export BEARER_TOKEN='your_bearer_token'For user actions (post, like, repost, bookmark, etc.):
export CLIENT_ID='your_client_id'
export CLIENT_SECRET='your_client_secret'Note: Most user action examples require OAuth 2.0 authentication with CLIENT_ID and CLIENT_SECRET. Read-only examples (search, lookup) only require BEARER_TOKEN.
# Compile a single file
javac -cp ".:lib/*" posts/SearchRecent.java
# Or compile all files
find . -name "*.java" -exec javac -cp ".:lib/*" {} \;# Run a single example
java -cp ".:lib/*" posts.SearchRecent
# Or with package structure
java -cp ".:lib/*" posts/RecentSearchDemo| Back | FazBrowse Home | New Git URL |