はじめて質問させていただきます。
柳沼と申します。
PHPを触り始めて2年程度の初心者です。
わからないことばかりではありますが、お助け下さい。
Google Calender API を利用して祝日・振替休日の表示が可能なカレンダーを表示させようとしたところ、
file_get_contents() [function.file-get-contents]: SSL: fatal protocol error
のようなエラーが表示されてしまいました。
xamppを使ったローカル環境上では普通に表示できております。
allow_url_fopen は On になっておりました。
ローカルはPHP Version 5.5.11
サーバーはPHP Version 5.1.6
です。
また、ネット上で「OpenSSLの設定が・・・」のようなものもあったのでphpinfoでみたところ
【curl】
CURL support enabled
CURL Information libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
【openssl】
OpenSSL support enabled
OpenSSL Version OpenSSL 0.9.8b 04 May 2006
というのがあるだけでした。
制限の厳しいレンタルサーバーのため、php.iniの設定などは行うことができません。
何卒宜しくお願い致します。
lang
1<?php 2 3print_r(get_holidays_this_month(2014,11)); 4 5 6function get_holidays_this_month($year, $month){ 7 // 月初日 8 $first_day = mktime(0, 0, 0, intval($month), 1, intval($year)); 9 // 月末日 10 $last_day = strtotime('-1 day', mktime(0, 0, 0, intval($month) + 1, 1, intval($year))); 11 $api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'; //←api_keyは取得、ローカルでの動作は確認できてます。 12 $holidays_id = 'outid3el0qkcrsuf89fltf7a4qbacgt9@import.calendar.google.com'; // mozilla.org版 13 //$holidays_id = 'japanese__ja@holiday.calendar.google.com'; // Google 公式版日本語 14 //$holidays_id = 'japanese@holiday.calendar.google.com'; // Google 公式版英語 15 $holidays_url = sprintf( 16 'https://www.googleapis.com/calendar/v3/calendars/%s/events?'. 17 'key=%s&timeMin=%s&timeMax=%s&maxResults=%d&orderBy=startTime&singleEvents=true', 18 $holidays_id, 19 $api_key, 20 date('Y-m-d', $first_day).'T00:00:00Z' , // 取得開始日 21 date('Y-m-d', $last_day).'T00:00:00Z' , // 取得終了日 22 31 // 最大取得数 23 ); 24 if ( $results = file_get_contents($holidays_url) ) { 25 $results = json_decode($results); 26 $holidays = array(); 27 foreach ($results->items as $item ) { 28 $date = strtotime((string) $item->start->date); 29 $title = (string) $item->summary; 30 $holidays[date('Y-m-d', $date)] = $title; 31 } 32 ksort($holidays); 33 } 34 return $holidays; 35}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2014/11/21 00:21
2014/11/21 00:30
2014/11/21 00:34
退会済みユーザー
2014/11/21 02:08