mastodon 0.3.1 copy "mastodon: ^0.3.1" to clipboard
mastodon: ^0.3.1 copied to clipboard

A simple API client for Mastodon access.

example/mastodon_example.dart

// Copyright (c) 2017, mike. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

import 'dart:convert';
import 'dart:io';

import 'package:mastodon/mastodon.dart';

void main() async {
  final properties = jsonDecode(File('lib/config.json').readAsStringSync());

  // Create your instance. Doesn't actually log on until you call a method.
  final m = Mastodon.usingAccessToken(
    properties['access_token'],
    instance: properties['instance'],
  );

  // Search for a user
  for (var account in await m.findAccounts('myk')) {
    print(account.username);
  }

  // Create a post with an image attached.
  final img = File('test/jackhammer.png').readAsBytesSync();
  final attachment = await m.postMedia(img, 'image/png');

  final post = Post(
      status: "It's Jackhammer Jill!",
      media_ids: [attachment.id],
      visibility: "private");
  final status = await m.postStatus(post);
  await m.deleteStatus(status.id);
}
4
likes
30
pub points
12%
popularity

Publisher

unverified uploader

A simple API client for Mastodon access.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

freezed_annotation, http, http_parser, json_annotation, mime, oauth2

More

Packages that depend on mastodon