Google カレンダー API (PHP) の v3 を使用してイベントを挿入できません。
イベントの説明にポンド記号 £ などの文字が含まれている場合、イベントはカレンダーに作成されますが、説明は空白のままになります。これは、最初の 7 ビット文字コード (ASCII コード 0 ~ 127) 以外のすべての文字に当てはまるようです。
htmlentities 関数を使用することで、シャープ記号のすべてのインスタンスを次のように置き換えることができます。£
ユーザーがウェブベースの Google カレンダーを使用している場合、これは問題ありませんが、モバイル アプリはこれをポンド記号に変換しません。
非 ASCII 引用符を使用する Microsoft Word からイベントがコピー/貼り付けされることが多いため、これは非常に大きな問題です。
これを回避する特定のエンコード方法はありますか? 現在、MySQL データベースと PHP スクリプトで UTF-8 エンコーディングを使用しています。
次のコードを使用してイベントを作成しています。
function buildGoogleEvent($title,$description,$start_time,$end_time,$location) {
// Create an event object and set some basic event information
$event = new Google_Event();
$event->setSummary($title);
$event->setLocation($location);
$event->setDescription(htmlentities($description, ENT_NOQUOTES, 'utf-8'));
// Convert the start and end date/times to ATOM format
$start_time_atom = str_replace(" ", "T", $start_time);
$end_time_atom = str_replace(" ", "T", $end_time);
// Add the event start to the event object
$start = new Google_EventDateTime();
$start->setDateTime($start_time_atom);
$start->setTimeZone('Europe/London');
$event->setStart($start);
// Add the event end to the event object
$end = new Google_EventDateTime();
$end->setDateTime($end_time_atom);
$end->setTimeZone('Europe/London');
$event->setEnd($end);
return $event;
}
そして、このコードはイベントを挿入します:
$createdEvent = $service->events->insert($google_calendar_id, $event);
かなり長い間これに座っていたので、助けていただければ幸いです! 私のPHPバージョンは5.5.4です。