我試圖從我的web應用程序插入谷歌日曆中的事件描述,我不能\ n或<br />
被解釋爲換行符。 Google日曆如何解釋換行符?幫助將不勝感激!Google Calendar API的換行符?
4
A
回答
-1
「/ n」僅適用於iCal條目。使用Google Calendar API,您不能執行換行。
0
我不確定谷歌日曆是如何解釋新行,但似乎每行有121個字符。
所以說,你想把「地址:」/ n的細節谷歌日曆。
以121減去「地址:」的字符數並將113個空格添加到「地址:」
以下文本應在新行上。
如果您發送的文本是一個PHP變量,在PHP中創建新行更容易。
$description = 'Description:'.'\n';
然後谷歌日曆將它作爲一個新行讀取它。
1
您是否使用特定的客戶端庫?如果使用的協議,簡單地將新行的內容元素應該工作:
<?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>
如果使用客戶端庫,使用「\ n」應該正常工作。
1
Heredocs是我如何運作的。
$content = <<<EOT
This
is
my
content
EOT;
您不能定界符的內部循環,但你可以建立起來,像這樣
$content = '';
for ($vars as $var) {
$content .= <<<EOT
$var
EOT;
}
1
使用API V3,這個工作對我來說:
$full_description .= 'Evento organizado por: ' . $area_responsavel . "\n\n"; $full_description .= $mensagem;
+1
單個「\ n」爲我工作。雖然使用雙引號很重要! (單引號不起作用) – tiho
1
用這個在google日曆事件描述中創建一個換行符:
\\n
蘭德爾麥格林寫在註釋中正確答案:
我敢肯定,一些在過去3年中已經改變,因爲這個問題被問,但你現在可以做到這一點。你只需要爲JSON格式化你的字符串。 「\ n」變成「\ n」。
相關問題
- 1. Google Calendar API V3
- 2. Google Calendar API getRefreshToken
- 3. Google Calendar Ruby API
- 4. Google Calendar API ClassDefNotFoundException
- 5. Google Calendar API,Google_Service類
- 6. Google Calendar API Javascript Quickadd
- 7. Google Calendar API集成
- 8. Google Calendar API和Coldfusion
- 9. Google App Engine和Google Calendar API
- 10. Google Calendar API V3刪除API
- 11. Google Calendar API中的「keyExpired」
- 12. Spring3的Google Calendar API庫?
- 13. Google Calendar API與會者VB
- 14. Google Calendar Api Android:403錯誤
- 15. Zend GData,Google Calendar API問題
- 16. Google Calendar API Python文檔
- 17. 如何實施Google Calendar API
- 18. Google Calendar API日期時間
- 19. 如何獲得Google Calendar API?
- 20. Google Calendar API V3 - 與會者
- 21. Google Calendar API - PHP - 「Class'apiClient'not found」
- 22. Google Calendar v3 api添加ExtendedProperties
- 23. Google Calendar API活動地點
- 24. Google Calendar API刷新accessToken
- 25. Google Calendar API適用性
- 26. Google Calendar API與Asp.net集成
- 27. Google Calendar API v3 PHP和JSON
- 28. Google Calendar API事件插入
- 29. Java中的安全API AuthSub(Google Calendar API)
- 30. Calendar Calendar like Google Calendars
所以它不可能有事件描述的換行符...? – Ben
通過Google API,是的。通過iCal界面,您可以使用「\ n」 –
我確信在問題提出後的過去3年中發生了一些變化,但您現在可以做到這一點。你只需要爲JSON格式化你的字符串。 「\ n」變成「\\ n」。這是一個有用的C#函數來做到這一點: http://stackoverflow.com/questions/1242118/how-to-escape-json-string/21455488#21455488 – Vandel212