. */ require 'lib/mastodon.php'; require 'lib/ckratelimit.php'; $resp=[ 'ok'=>false, 'error'=>null, 'remaining'=>null, 'secstoreset'=>null, 'id'=>null ]; if (isset($_COOKIE['verbose_host']) && isset($_COOKIE['verbose_token']) && isset($_POST['visibility']) && in_array($_POST['visibility'],['public','unlisted','private','direct']) && isset($_POST['language']) && isset($_POST['status'])) { $timeout=5; $res=mastpost($_COOKIE['verbose_host'],$_COOKIE['verbose_token'],'/api/v1/statuses',$_POST,$timeout); //$res=['ok'=>true, 'data'=>['id'=>999], 'error'=>'server exploded'];// test if ($res['ok']) { $resp['ok']=true; $resp['id']=$res['data']['id']; $rls=ckratelimit($res['headers']); //$rls=['ok'=>true,'remaining'=>20,'sleep'=>5];// test if ($rls['ok']) { $resp['remaining']=$rls['remaining']; $resp['secstoreset']=$rls['sleep']; } } else { $resp['error']=htmlentities($res['error']); } } else { $resp['error']='malformed POST request'; } header('Content-Type: application/json'); $resp=json_encode($resp); echo $resp; //echo '
'.print_r($_POST,true).'
'; ?>