API-Medium
view release on metacpan or search on metacpan
Installing API-Medium is straightforward.
## Installation with cpanm
If you have cpanm, you only need one line:
% cpanm API::Medium
If it does not have permission to install modules to the current perl, cpanm
will automatically set up and install to a local::lib in your home directory.
See the local::lib documentation (https://metacpan.org/pod/local::lib) for
details on enabling it in your environment.
## Installing with the CPAN shell
Alternatively, if your CPAN shell is set up, you should just be able to do:
% cpan API::Medium
## Manual installation
As a last resort, you can manually install it. Download the tarball, untar it,
install configure prerequisites (see below), then build it:
% perl Build.PL
% ./Build && ./Build test
## Authentication
### OAuth2 Login
Not implemented yet, mostly because medium only support the "web
server" flow and I'm using `API::Medium` for an installed
application.
### Self-issued access token / Integration token
Go to your [settings](https://medium.com/me/settings), scroll down to
"Integration tokens", and either create a new one, or pick the one you
want to use.
# Methods
## new
my $m = API::Medium->new({
access_token => $token,
});
/publications/{{publicationId}}/contributors
## create\_post
my $url = $m->create_post( $user_id, $post_data );
Create a new post. If you pass in bad data, Medium will probably
report an error.
`publishStatus` is set to 'draft' unless you pass in another value.
## create\_publication\_post
my $url = $m->create_publication_post( $publication_id, $post_data );
Create a new post under a publication. You will need to figure out the
publication\_id by calling the API from the commandline (until
`publications` is implemented.)
If you pass in bad data, Medium will probably report an error.
`publishStatus` is set to 'draft' unless you pass in another value.
## TODO
- OAuth2 Login
- Get a new access\_token from refresh\_token
- `publications`
- `contributors`
## Thanks
lib/API/Medium.pm view on Meta::CPAN
=head2 Authentication
=head3 OAuth2 Login
Not implemented yet, mostly because medium only support the "web
server" flow and I'm using C<API::Medium> for an installed
application.
=head3 Self-issued access token / Integration token
Go to your L<settings|https://medium.com/me/settings>, scroll down to
"Integration tokens", and either create a new one, or pick the one you
want to use.
=head1 Methods
=head2 new
my $m = API::Medium->new({
access_token => $token,
});
lib/API/Medium.pm view on Meta::CPAN
/publications/{{publicationId}}/contributors
=head2 create_post
my $url = $m->create_post( $user_id, $post_data );
Create a new post. If you pass in bad data, Medium will probably
report an error.
C<publishStatus> is set to 'draft' unless you pass in another value.
=head2 create_publication_post
my $url = $m->create_publication_post( $publication_id, $post_data );
Create a new post under a publication. You will need to figure out the
publication_id by calling the API from the commandline (until
C<publications> is implemented.)
If you pass in bad data, Medium will probably report an error.
C<publishStatus> is set to 'draft' unless you pass in another value.
=head2 TODO
=over
=item * OAuth2 Login
=item * Get a new access_token from refresh_token
=item * C<publications>
( run in 0.827 second using v1.01-cache-2.11-cpan-49f99fa48dc )