Advertisement
mazudi

Untitled

May 26th, 2012
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. <?php
  2. function getPage($url, $referer, $timeout){
  3. if(!isset($timeout))
  4. $timeout=30;
  5. $curl = curl_init();
  6. if(strstr($referer,"://")){
  7. curl_setopt ($curl, CURLOPT_REFERER, $referer);
  8. }
  9. curl_setopt ($curl, CURLOPT_URL, $url);
  10. curl_setopt ($curl, CURLOPT_TIMEOUT, $timeout);
  11. curl_setopt ($curl, CURLOPT_USERAGENT, sprintf("Mozilla/%d.0",rand(4,5)));
  12. //curl_setopt ($curl, CURLOPT_HEADER, (int)$header);
  13. curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
  14. curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0);
  15. $html = curl_exec ($curl);
  16. curl_close ($curl);
  17. return $html;
  18. }
  19.  
  20. $url = 'https://www.google.com/calendar/feeds/pomepure.calendar%40gmail.com/public/full?alt=json&orderby=starttime&max-results=15&singleevents=true&sortorder=ascending&futureevents=true';
  21. //$content=fopen($url, "r");
  22. $content=getPage($url, 'http://google.com', '30');
  23. $decode=json_decode($content);
  24. $feed=$decode->feed;
  25. for($i=0; $i<=10; $i++){
  26. echo "<div id=\"gcalblock\">\n";
  27. $t1='$t';
  28. $when='gd$when';
  29. $where='gd$where';
  30.  
  31. $bila=$feed->entry[$i]->$when;
  32. echo "<div id=\"left\">\n";
  33. foreach($bila as $bila){
  34. $startday=date('d M Y',strtotime($bila->startTime));
  35. $endday=date('d M Y',strtotime($bila->endTime));
  36. $starttime=date('h:i a',strtotime($bila->startTime));
  37. $endtime=date('h:i a',strtotime($bila->endTime));
  38. $sbulan=date('F',strtotime($bila->startTime));
  39. $sday=date('d',strtotime($bila->startTime));
  40. $syear=date('Y',strtotime($bila->startTime));
  41.  
  42. if($startday==$endday){
  43. echo $sbulan."<br>\n";
  44. echo "<h2>".$sday."</h2>\n";
  45. echo $syear."\n";
  46.  
  47. }else{
  48. echo "From $startday at $starttime to $endday at $endtime<br>";
  49. }
  50. echo "</div>\n";
  51. echo "<div id=\"right\">\n";
  52. echo "<h3>".$feed->entry[$i]->title->$t1."</h3>\n";
  53. echo $starttime." - ".$endtime."<br>\n";
  54. $mana=$feed->entry[$i]->$where;
  55. foreach($mana as $mana){
  56. echo $mana->valueString."<br><br>\n";
  57. }
  58. echo $feed->entry[$i]->content->$t1."<br>\n";
  59.  
  60. echo "</div>\n";
  61. }
  62. echo "</div>\n";
  63. echo "<br clear=\"all\">\n";
  64. }
  65. //echo "<pre>";
  66. //print_r($decode);
  67. //echo "</pre>";
  68.  
  69. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement