yks118 / Mastodon-api-php

A GNU Social-compatible microblogging server https://mastodon.social PHP API
MIT License
20 stars 9 forks source link

Token not valid to write toots... #3

Open pperrin opened 6 years ago

pperrin commented 6 years ago

This is the hacked down version of my code (variables are defined in the 'live' version).

The app is setup read/write/follow on the server for a user, the user info so correctly shown from the verify, but try to toot and it blows.

I have tried various things (an admin account, login instead of using the profile token etc) -- but all with the same result...

Any ideas? Or suggestions on where to look to debug this?

<?php
require_once 'mastodon_api.php';
$mastodon_api = new Mastodon_api();
$mastodon_api->set_url($url);
$mastodon_api->create_app($appname,null,null,$url);
$mastodon_api->set_client($key,$secret);
$mastodon_api->set_token($token,'bearer');
print '<pre>';
print "verify\n";
$ret = $mastodon_api->accounts_verify_credentials();
var_dump($ret);

print "post\n";
$ret = $mastodon_api->post_statuses(array('status' => 'Test Auto Post'));
var_dump($ret);
print '</pre>';

Everything works untill it tries to create a toot and it gives the following:-

  ["html"]=>
  array(1) {
    ["error"]=>
    string(27) "The access token is invalid"
  }
  ["response"]=>
  array(27) {
    ["url"]=>
yks118 commented 5 years ago

Hi.

Sorry.

This is lib not oauth.

plz click url. https://github.com/yks118/Mastodon-api-php-oauth