Skip to content

A library for authenticating and accessing the Pocket API from Dart

License

Notifications You must be signed in to change notification settings

Ne4istb/pocket_client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pub Package Build Status Coverage Status Github Issues

pocket_client

A library for authenticating and accessing the Pocket API from Dart

Quick start

Authentication:
import 'package:pocket_client/pocket_client.dart';

const consumerKey = '1234-abcd1234abcd1234abcd1234';
const redirectUrl = 'http://some.redirect.uri/autorizationFinished';

main() async {
  var authentication = new ClientAuthentication(consumerKey);

  var requestToken = await authentication.getRequestToken(redirectUrl);
  var url = ClientAuthentication.getAuthorizeUrl(requestToken, redirectUrl);
  // work whatever redirect magic you need here

  //..

  var userData = await authentication.getAccessToken(requestToken);
  onAuthorizationFinished(userData.accessToken);
} 

onAuthorizationFinished(String accessToken) {
  // now you have everything to communicate with Pocket 
}
Working with Pocket:
import 'package:pocket_client/pocket_client.dart';

const consumerKey = '1234-abcd1234abcd1234abcd1234';
const accessToken = '5678defg-5678-defg-5678-defg56';

main() async {
  var client = new Client(consumerKey, accessToken);

  var options = new RetrieveOptions()
    ..since = new DateTime(2015, 5, 4)
    ..search = 'Some search query'
    ..domain = 'http://domain.test'
    ..contentType = ContentType.video
    ..detailType = DetailType.complete
    ..isFavorite = true
    ..sortType = SortType.site
    ..state = State.all
    ..tag = 'cats'
    ..count = 100
    ..offset = 10;

  var response = await client.getData(options: options);
  Map<String, PocketData> items = response.items;
  // do whatever you want with pocket items

  var newItem = new ItemToAdd('http://www.funnycatpix.com/')
    ..title = 'FUNNY CAT PICTURES'
    ..tweetId = '123456'
    ..tags = ['cats', 'cool', 'share'];

  PocketData data = await client.addItem(newItem);
  // do whatever you want with received data
}

Api

See the Api documentation.

Examples

The basic example is in example file

Features and bugs

Please fill feature requests and bugs at the issue tracker.

License

pocket_client is distributed under the BSD license.

About

A library for authenticating and accessing the Pocket API from Dart

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published