XCLI is a command-line interface (CLI) tool for interacting with the Twitter API. It allows developers to perform actions such as authenticating via OAuth 2.0, retrieving information from API endpoints, and working with Twitter Spaces. This project is designed with a focus on simplicity, modularity, and extensibility.
- OAuth 2.0 Authentication: Securely authenticate with Twitter using bearer tokens.
- Custom API Requests: Perform GET requests to specified Twitter API endpoints with query parameters.
- Twitter Spaces: Fetch detailed information about Twitter Spaces by providing a Space ID.
- Extensive Logging: Provides formatted error and info logs for better debugging and user feedback.
- C++ Compiler: A modern C++ compiler with support for C++20 or higher (e.g., GCC 10+, Clang 12+, or MSVC 2019+).
- Dependencies:
- cURL for HTTP requests.
- JSON for Modern C++ for parsing and generating JSON.
- Build Tools:
- CMake for building the project.
git clone https://github.com/genyleap/XCLI.git
cd XCLI
-
Create a build directory:
mkdir build && cd build
-
Run CMake to configure the build:
cmake ..
-
Build the project:
cmake --build .
xcli <command> [options]
-
auth
: Authenticate with Twitter using OAuth 2.0.xcli auth
-
get
: Perform a GET request to a specified API endpoint.xcli get <endpoint> [key=value ...]
Example:
xcli get /2/users/by/username/johndoe user.fields=id,name,username
-
space
: Fetch information about a Twitter Space using its Space ID.xcli space <space_id>
Example:
xcli space 1vOGwMNOZXYxB
Authentication successful.
Tokens saved successfully to "auth_tokens.json".
API Response:
{
"data": {
"id": "1vOGwMNOZXYxB",
"title": "Tech Talks",
"host_ids": ["123456789"],
"participant_count": 150,
"created_at": "2024-12-15T10:00:00Z"
}
}
XCLI/
├── source/ # Source code files & Header files
│ └── xcli.hpp # Declaration of XCLI class
│ ├── xcli.cpp # Main implementation of XCLI
│ └── ...
├── third-party/ # Third-party dependencies (e.g., JSON library)
├── CMakeLists.txt # CMake configuration
└── README.md # Project documentation
Modify the following constants in xcli.hpp
as needed:
tokenFile
: Path to the JSON file where authentication tokens are stored.
Contributions are welcome! If you have ideas or improvements, feel free to submit a pull request or open an issue.
- Fork the repository.
- Create a new branch:
git checkout -b feature/your-feature
- Commit your changes:
git commit -m "Add your feature description"
- Push to your fork:
git push origin feature/your-feature
- Submit a pull request.
This project is licensed under the MIT License.
- Twitter API for providing access to social data.
- cURL for HTTP requests.
- JSON for Modern C++ for JSON parsing.