4

ウェブサイトに何か新しいものを追加するたびに自動 tumblr 投稿を設定しようとしています。私は次のコードを使用しています:

$conskey = "APIKEY";
$conssec = "APISECRET";

$tumblr_blog = "blogname.tumblr.com";
$to_be_posted = "This is the text to be posted";

$oauth = new OAuth($conskey,$conssec);
$oauth->fetch("http://api.tumblr.com/v2/blog/".$tumblr_blog."/post", array('type'=>'text', 'body'=>$to_be_posted), OAUTH_HTTP_METHOD_POST);

$result = json_decode($oauth->getLastResponse());

if($result->meta->status == 200){
    echo 'Success!';
}

私が知る限り、これはすべて正しくフォーマットされています。ただし、Oauth を使用して JSON API に接続しようとしたのはこれが初めてなので、自分がしていることに完全に自信があるわけではありません。

これは私が受け取っている正確なエラーです:

Fatal error: Uncaught exception 'OAuthException' with message 'Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a redirect)' in /home/public_html/edge/tumblr.php:35 Stack trace: #0 /home/public_html/edge/tumblr.php(35): OAuth->fetch('http://api.tumb...', Array, 'POST') #1 /home/public_html/edge/index.php(95): include('/home/...') #2 {main} thrown in /home/public_html/edge/tumblr.php on line 35

35 行目は $oauth->fetch で始まる行です。

助けてくれてありがとう:-)

編集以前のコードをこのページ の例に置き換えることで問題を解決しました

4

0 に答える 0