Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kiliczsh/instagram-nuget
NuGet Package for Instagram Basic Display API Client
https://github.com/kiliczsh/instagram-nuget
instagram not-published nuget
Last synced: about 1 month ago
JSON representation
NuGet Package for Instagram Basic Display API Client
- Host: GitHub
- URL: https://github.com/kiliczsh/instagram-nuget
- Owner: kiliczsh
- License: mit
- Created: 2024-07-15T18:28:46.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-07-15T18:46:11.000Z (6 months ago)
- Last Synced: 2024-11-26T16:44:08.905Z (about 1 month ago)
- Topics: instagram, not-published, nuget
- Language: C#
- Homepage:
- Size: 15.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Instagram Library
The `Instagram` library provides a simple and easy-to-use client for interacting with the Instagram API. This library helps you handle common tasks such as obtaining access tokens, exchanging short-lived tokens for long-lived ones, refreshing tokens, and retrieving user profiles and media.
## Installation
Install the package via NuGet:
```bash
dotnet add package Instagram
```## Configuration
Add your Instagram settings to the appsettings.json file:
```json
{
"InstagramSettings": {
"ClientId": "your-client-id",
"ClientSecret": "your-client-secret",
"RedirectUri": "https://localhost:8081/api/instagram/callback"
}
}
```## ASP.NET Core Setup
In your Program.cs or Startup.cs file, configure the InstagramClient and its dependencies:
```csharp
// Instagram Client Configuration
builder.Services.Configure(builder.Configuration.GetSection("InstagramSettings"));
builder.Services.AddHttpClient();
```Usage
You can now inject and use the InstagramClient in your controllers or services. Here’s an example of how to use it in a controller:
```csharp
public class InstagramController : Controller
{
private readonly IInstagramClient _instagramClient;public InstagramController(IInstagramClient instagramClient)
{
_instagramClient = instagramClient;
}public async Task SignIn()
{
var url = _instagramClient.GetAuthorizationUrl();
return Redirect(url);
}public async Task Callback(string code)
{
var token = await _instagramClient.GetAccessToken(code);
var user = await _instagramClient.GetUserProfile(token.AccessToken);
var media = await _instagramClient.GetUserMedia(token.AccessToken, user.Id);
return Ok(media);
}
}
```## Methods
The InstagramClient class provides the following methods:
```csharp
string GetAuthorizationUrl()
Task GetAccessTokenAsync(string code)
Task ExchangeForLongLivedTokenAsync(string shortLivedToken)
Task RefreshLongLivedTokenAsync(string longLivedToken)
Task GetUserProfileAsync(string accessToken)
Task GetUserMediaAsync(string accessToken)
Task GetMediaAsync(string mediaId, string accessToken)
Task GetMediaChildrenAsync(string mediaId, string accessToken)
Task> GetAllUserMediaAsync(string accessToken)
```## License
See the LICENSE file for more details.
## Contributing
Contributions are welcome! Please open an issue or submit a pull request.