项目作者: thosakwe

项目描述 :
Dart Instagram client library.
高级语言: Dart
项目地址: git://github.com/thosakwe/instagram_dart.git
创建时间: 2017-07-18T17:34:46Z
项目社区:https://github.com/thosakwe/instagram_dart

开源协议:MIT License

下载


ARCHIVED

See the reasons here: https://github.com/thosakwe/instagram_dart/issues/8

instagram

Pub

NOTE: The old Instagram API is now deprecated; this package will now focus on the Instagram Graph API.

Dart Instagram client library. This library includes support for authentication,
as well as all of the Instagram API v1 endpoints.

The API is entirely documented, for convenience. :+1:

Users of
Angel
can use
package:angel_auth_instagram
to authenticate users with Instagram.

Coming soon: Subscriptions

Authentication

Via Access Token

If you already have an access token, you can authenticate a client.

Note: The user property of the InstagramClient will be null.

  1. var client = InstagramApiAuth.authorizeViaAccessToken('<access-token>');
  2. var me = await client.users.self.get();

InstagramApiAuth

To perform authentication, use the InstagramApiAuth class. All API scopes are
included as InstagramApiScope constants for convenience.

  1. var auth = new InstagramApiAuth('<client-id>', '<client-secret>',
  2. redirectUri: Uri.parse('<redirect-uri>'),
  3. scopes: [
  4. InstagramApiScope.basic,
  5. InstagramApiScope.publicContent,
  6. // ...
  7. ]
  8. );

Implicit Auth

Applications with no server-side component can implement
implicit auth.

To get a redirect URI:

  1. var redirectUri = auth.getImplicitRedirectUri();
  2. window.location.href = redirectUri.toString();

Explicit Auth

This library also supports traditional OAuth2 authentication.

To obtain a redirect URI:

  1. var redirectUri = auth.getRedirectUri();
  2. var redirectUri = auth.getRedirectUri(state: 'foo.bar=baz');
  3. res.redirect(redirectUri.toString());

After you have obtained an authorization code, you can exchange it for an access token,
and receive an InstagramClient.

This example is an
Angel
handler:

  1. app.get('/auth/instagram/callback', (RequestContext req, InstagramApiAuth instaAuth) async {
  2. var client = await instaAuth.handleAuthorizationCode(req.query['code'], new http.Client());
  3. var me = await client.users.self.get();
  4. // Do something with the authenticated user...
  5. });

You can also manage
subscriptions:

  1. main() {
  2. var subscriptions = instaAuth.createSubscriptionManager(new http.Client());
  3. }

Endpoints

The InstagramClient contains several getters that correspond to endpoints. Each is an abstraction over
a specific Instagram API.

Here is an example with the relationships API:

  1. Future<bool> userFollowsMe(String userId, InstagramClient instagram) async {
  2. var relationship = await instagram.relationships.toUser(userId).get();
  3. return relationship.incomingStatus == IncomingStatus.followedBy;
  4. }

Constants

This API includes several classes containing helpful constants:

  • InstagramApiScope
  • IncomingStatus
  • OutgoingStatus
  • RelationshipAction
  • MediaType
  • SubscriptionObject
  • SubscriptionAspect