(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化)のその後