[英]returning json from google calendar and parsing with php
$current = $_GET['current'];
$future = $_GET['future'];
//$CMD = $_GET['CMD'];
$current = mktime(0,0,0,date("m"),date("d"),date("Y"));
$currentDate = date("Y-m-d",$current);
$future = mktime(0,0,0,date("m"),date("d")+7,date("Y"));
$futureDate = date("Y-m-d", $future);
//need to get the futureDate for URL
//$futrureDate = date("Y-m-d",$_GET['finalDate'])
// build feed URL
$googleURL = "http://www.google.com/calendar/feeds/$userid/private-$magicWord/basic?start-min=$currentDate&start-max=$futureDate/full?alt=json";
//$googleURL = "http://www.google.com/calendar/feeds/$userid/private-$magicWord/basic?alt=json";
//$url = "http://www.google.com/calendar/feeds/developer-calendar@google.com/public/full?alt=json";
$data = file_get_contents($googleURL);
echo $data;
//$json = json_encode($data);
//echo $json;
//By default json_decode returns an stdClass object. You have to give a second parameter for this function TRUE.
$object = json_decode($json,TRUE);
print_r($object->title[1]);
//echo $object->title[0];
我在哪里將alt = json與日期變量一起放在url中。 當我從網址中排除日期,但隨后它們對它們無效時,它的效果很好。 另外,當我嘗試打印特定對象時,我收到該對象不存在的錯誤消息。 謝謝!
嘗試-
$googleURL = "http://www.google.com/calendar/feeds/$userid/private-$magicWord/basic?start-min=$currentDate&start-max=$futureDate/full&alt=json";
似乎URL方案要求基本視圖,然后添加完整視圖。 (您只能有一個。)
嘗試以下任一方法:
$googleURL = "http://www.google.com/calendar/feeds/$userid/private-$magicWord/basic?start-min=$currentDate&start-max=$futureDate&alt=json";
要么
$googleURL = "http://www.google.com/calendar/feeds/$userid/private-$magicWord/full?start-min=$currentDate&start-max=$futureDate&alt=json";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.