Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ohmycloud/fanfou-p6
Oauth Client For fanfou, Written in Raku
https://github.com/ohmycloud/fanfou-p6
fanfou oauth-client raku
Last synced: 10 days ago
JSON representation
Oauth Client For fanfou, Written in Raku
- Host: GitHub
- URL: https://github.com/ohmycloud/fanfou-p6
- Owner: ohmycloud
- License: artistic-2.0
- Created: 2018-05-11T17:07:54.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-28T09:03:59.000Z (about 6 years ago)
- Last Synced: 2025-01-12T13:22:38.512Z (11 days ago)
- Topics: fanfou, oauth-client, raku
- Language: Perl 6
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## DESCRIPTION
FanFou is a oauth client inspared by [fanfou-py](https://docs.setq.me/oh-my-robot/fanfou-api.html).
The module provides several ways to authorize, see [Fanfou API OAuth](https://github.com/FanfouAPI/FanFouAPIDoc/wiki/Oauth) for more details.
## Write Your Own Robot
![img](http://photo1.fanfou.com/v1/mss_3d027b52ec5a4d589e68050845611e68/ff/n0/0f/qm/xd_368058.jpg@596w_1l.jpg)
```perl6
use FanFou;
my %oauth_consumer = key => 'your_consumer_key', secret => 'your_secret_key';# get client
my $client = FanFou::XAuth.new(oauth_consumer => %oauth_consumer, username => 'your_username', password => 'your_password');# get response
my $resp = from-json await $client.request('/statuses/home_timeline', 'GET').body-text;
say $resp.perl;# post a message
my %body = 'status' => "Hi, fan, I'm a robot";
$client.request('/statuses/update', 'POST', %body);
```You can use `Terminal::ANSIColor` and `Terminal::Spinners` for better format and experience:
```perl6
use FanFou;
use JSON::Fast;
use Terminal::ANSIColor;
use Terminal::Spinners;sub MAIN($str?) {
my %oauth_consumer = key => 'xxx', secret => 'xxx';
my $client = FanFou::XAuth.new(oauth_consumer => %oauth_consumer, username => 'xxx', password => 'xxx');if $str.defined {
# post a message
my %body = 'status' => "$str";
$client.request('/statuses/update', 'POST', %body);
} else {my $dots = Spinner.new: type => 'dots';
my $promise = start {
my $resp = from-json await $client.request('/statuses/home_timeline', 'GET').body-text;
say '';
for @$resp.sort(*.{'user'}.{'unique_id'}) -> $p {
say '[' , colored("{$p.{'user'}.{'name'}}", "{(^256).pick}"), '] ', $p.{'text'};
}
}; # promise of your long running process
until $promise.status {
$dots.next; # prints the next spinner frame
}
}
}
```## AUTHOR
## COPYRIGHT AND LICENSE
Copyright 2018
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.