New line for Google Calendar Api?

I am trying to insert an event description into the Google calendar from my web application, and I cannot force \ n or <br /> interpreted as a line break. How does a Google calendar interpret newlines? Help will be appreciated!

+5
source share
6 answers

"/ n" only works for iCal entries. Using the Google Calendar API, you cannot use newline characters.

-1
source

Are you using a specific client library? If you use the protocol, you just need to put a new line in the content element:

 <?xml version="1.0" encoding="UTF-8"?> <entry xmlns="http://www.w3.org/2005/Atom" xmlns:gCal="http://schemas.google.com/gCal/2005" xmlns:gd="http://schemas.google.com/g/2005"> <title type="text">Event with new line</title> <content type="text">This is an event with one two three and and four lines.</content> <gd:when endTime="2011-12-23T10:00:00.000-07:00" startTime="2011-12-23T08:00:00.000-07:00"/> </entry> 

If you are using the client library, using \ n should work.

+1
source

Heredocs is how I got it to work.

 $content = <<<EOT This is my content EOT; 

You cannot loop in the heredoc, but you can create it this way

 $content = ''; for ($vars as $var) { $content .= <<<EOT $var EOT; } 
+1
source

Using the V3 API, this worked for me:

$full_description .= 'Evento organizado por: ' . $area_responsavel . "\n\n"; $full_description .= $mensagem;

+1
source

Use this to create a line break in the description of a Google Calendar event:

 \\n 

Randall McGlynn wrote the correct answer in the comments:

I'm sure something has changed in the last 3 years since this question was asked, but now you can do it. You just need to format the string for JSON. \n becomes \\n .

+1
source

I'm not sure if the Google calendar interprets newlines, but it looks like 121 lines per line.

So, say you want to put “Address:” / n in the details of the Google calendar.
Take 121, subtract the number of characters "Address:" and add 113 spaces to "Address:"

The following text should be on a new line.

Even easier, if the text of your submission is a PHP variable, enter a new line in php.

 $description = 'Description:'.'\n'; 

Then the Google calendar will consider it a new line.

0
source

All Articles