[X] You are not permitted to perform this action [Twitter]

この記事は約2分で読めます。
スポンサーリンク

当サイトには広告が含まれています。

(2025年8月)

X(旧Twitter)にAPI経由でpostした際に

[detail] => You are not permitted to perform this action.
[type] => about:blank
[title] => Forbidden
[status] => 403

を返してくる時は、Twする文字列にHTMLタグが含まれていないかを確認しよう。

PHPならstrip_tagsで取り除くとか。

タグを含まない文字列をstrip_tagsで処理してもエラーにはならないが、タグを含むかを判断するなら、以下を使うとか。


function tag_umu($string){

 if(preg_match("/<.*>/",$string)){

  return $string ;

 }else{

  return false ;

 }// if

}// function tag_umu

なお、投稿文字数制限(無料プランで140文字)の超過でハヂかれた場合は、

[message] => Your Tweet text is too long.

を返してくるので、上記とは区別できる。

関連:TwitterのAPI仕様変更(HTTPS化)のその後

関連:XのAPI改悪によりTweet(投稿)が止まる事案

タイトルとURLをコピーしました