LoginSignup
0
0

More than 3 years have passed since last update.

Twitter Web Intentで、URLの中に、| (vertical bar)があると、400エラーが起こる解決法

Last updated at Posted at 2020-04-22

背景

  • TwitterのWeb Intent Tweetを、Wordpressから利用して、シェアする導線を強いたときに、ページタイトルに | (vertical bar)が存在した
  • Twitter上のURLで、|(Vertical Bar)を利用すると、400エラーがでてしまう

試したこと

  • ページタイトルに、urlencode関数でエンコーディングしてみたが、なぜか | (vertical bar)がエンコードされない

解決方法

  • urlencodeした関数を、さらにstr_replace関数で、無理やり | (vertical bar)を変換
  • | はエンコードすると、%7C
<?php echo urlencode(str_replace('|', '%7C', $title)); ?>

最後に

かなり無理やり対応してしまったが、もっといいやり方があるような気がするので、ご教授いただけると嬉しいです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0