Jump to content
php.lv forumi
Sign in to follow this  
ziedinjsh

PHP ģenerē ICS failu, bet android nevar palaist

Recommended Posts

Sveiki, mēģinu palaist uz android kalendāru savu .ics failu, bet android nenolasa. Caur online ics validatoru man parādu šādu kļūdu:  Missing VCALENDAR object near line # 1Reference: RFC 5545 3.4 iCalendar Object Mans kods:
 

require_once('src/idiorm/dbase.php');
header("Content-Type: text/Calendar");
header("Content-Disposition: inline; filename=filename.ics");
$calendar ='
	BEGIN:VCALENDAR\n
	PRODID:-//kkas/kkas//v 0.1//LV
	VERSION:2.0\n
	METHOD:PUBLISH\n
	X-MS-OLK-FORCEINSPECTOROPEN:TRUE\n';
$events = ORM::for_table('events')->find_many();
foreach($events as $event){
	$id = $event->id;
	$uid = $event->uid;
	$startdate = $event->startdate;
	$enddate = $event->startdate;
	$title = $event->title;
	$desc = $event->description;
	$addtime = $event->addtime;
	$modifed = $event->last_modifed;
	$calendar .='BEGIN:VEVENT\n
		CLASS:PUBLIC\n
		CREATED:'.$addtime.'\n
		DESCRIPTION:'.$desc.'\n
		DTSTAMP:'.$addtime.'\n
		DTSTART:'.$startdate.'\n
		DTEND:'.$startdate.'\n
		LAST-MODIFIED:'.$modifed.'\n
		LOCATION:\n
		PRIORITY:5\n
		SEQUENCE:0\n
		SUMMARY:LANGUAGE=lv:'.$title.'\n
		TRANSP:OPAQUE\n
		UID:'.$id.'\n
		X-MICROSOFT-CDO-BUSYSTATUS:BUSY\n
		X-MICROSOFT-CDO-IMPORTANCE:1\n
		X-MICROSOFT-DISALLOW-COUNTER:FALSE\n
		X-MS-OLK-ALLOWEXTERNCHECK:TRUE\n
		X-MS-OLK-AUTOFILLLOCATION:FALSE\n
		X-MS-OLK-CONFTYPE:0\n
		END:VEVENT\n';
}	
	$calendar .='END:VCALENDAR';
	echo $calendar;
?>

Es īstiu nesaprotu kas nav pareizi!

P.S. Paldies jau iepriekš.

Share this post


Link to post
Share on other sites

Nemācēšu pateikt kur ir kļūda, bet kad es krāmējos ar ics, tad galā nonācu pie vienas ics php bibliotēkas, kas ļāva ērti visu oop stipā salikt. 
Iesaku neizgudrot riteni no jauna un pamēģināt atrast kādu gatavu libu. Beigās arī varēsi salīdzināt output starp savu un bibl. kodu, gan jau arī tad kļūdu pamanīsi.
 

Share this post


Link to post
Share on other sites

un ja paskatās tā jauniegūtā .ICS faila saturu, izskatās tāds pats kā izeksportēts no kādas kalendāra programmas, uz MACa kaut vai 'Calendar'?

un tas izeksportētais validējas?

 

Share this post


Link to post
Share on other sites

Diemžēl man nav Mac ierīce, lai notestētu. Pamiģināju šo libu. Vienu eventu viņš izveido un viss ir ok, bet kā lai viņu iestutēju iekš foreach, lai man vienā *.ics failā nav pie katra eventa BEGIN:VCALENDAR, bet gan BEGIN:EVENT???
Tālāk netieku
 

$events = ORM::for_table('events')->find_many();

$data = array();

$ics = new ICS($data);

foreach($events as $event){
	$data[] = array(
		'location' => 'Mājās',
		'description' => $event->description,
		'dtstart' => $event->startdate,
		'dtend' => $event->startdate,
		'summary' => $event->title,
		'url' => ''
	);
}

 

Edited by ziedinjsh

Share this post


Link to post
Share on other sites

Problēma izskatās ir tajā, ka tu newline simbolu \n raksti single pēdiņas. PHP visi special chari jāraksta ir dubultajās pēdiņās

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...