Google Calendar 的 JSON 應用
分類:
部落格
新版的 blogger.com 有個 HTML/Javascript 的 widget 區塊,可以很自由的放入一些程式碼,目前 google 宣佈全面支援 JSON 的規格,因此不用再利用 XMLRequest 的元件去解惱人的 XML 格式。
目前 blogger.com 的新版範本檢查的很嚴格,很多要寫死的資料並不建議直接放在範本上,利用 HTML/Javascript 這個 widget 也是放置資料的好方法。
JSON 的規格大致上就是利用Javascript src=http://domain.../?param=value 這種模式,用瀏覽器的內建解析HTML語法的同時就把程式碼下載到Client端,然後透過 Callback function 的宣告,只要下載回來就會觸發相關的function,資料利用 Array 的模式直接放在裡面,很簡單的取出資料然後做相關的應用顯示出來即可,要取多少資料,要如何排序,要怎樣顯示?都可以自己決定。
以下就是我利用 Google Calendar 提供的 feed,把最近三筆在日曆上的行程顯示出來,如何判斷最近?就是利用客戶端電腦的日期時間來判斷,然後依照時間排序顯示出這些資訊。程式碼如下:
<h2><a target="_blank" href="http://www.google.com/calendar/embed?src=mpmigkt2int30a57lakat0dn10%40group.calendar.google.com">《活動行程》</a><a target="_blank" href="http://www.google.com/calendar/feeds/mpmigkt2int30a57lakat0dn10%40group.calendar.google.com/public/full"><img border="0" src="http://www.google.com/calendar/images/xml.gif"/></a></h2>
<div id="divcalendar">下載中...</div>
<script>
function cal_Date(a){
var aa=a;
if (aa.length==10)
aa += 'T00:01:00.000+08:00';
return Date.parse(aa.replace(/^(\d{4})-(\d{2})-(\d{2})T([0-9:]*)([.0-9]*)(.)(.*)$/, '$1/$2/$3 $4 GMT'));
}
function cal_comp(a,b){
order= cal_Date(a.gd$when[0].startTime)- cal_Date(b.gd$when[0].startTime);
return order;
}
function cbcalendar(json)
{
var temp = '<ul id="feedItemListDisplay">';
var postshow=3;
var sortentry=json.feed.entry.sort(cal_comp);
var nowDate= new Date();
var j=0;
for (var i=0,post; post = sortentry[i]; i++) {
if(j>=postshow) break;
var title=post.title.$t;
var link=post.gd$where[0].valueString;
var startTime=post.gd$when[0].startTime;
var thisDate = cal_Date(startTime);
if (thisDate >= nowDate)
{
temp += '<li><a target="_blank" href="' + link + '">' + startTime.substring(0,10)+':'+title + '</a><br>' +'</li>';
j ++;
}
}
if (j==0)
temp += "<li>無資料</li>";
temp+="</ul>";
document.getElementById("divcalendar").innerHTML = temp;
}
</script>
<script src="http://www.google.com/calendar/feeds/mpmigkt2int30a57lakat0dn10%40group.calendar.google.com/public/full?alt=json-in-script&callback=cbcalendar" type="text/javascript"></script>
由於 google calendar 並沒有網址URL 的欄位,我是利用地點這個欄位來放網址,上面有行程式碼
var link=post.gd$where[0].valueString;
可以改成
var link=post.link[0].href;
就是 google calendar 那個行程的連結。
相關說明:http://code.google.com/apis/gdata/json.html
總共有61個迴響
好厲害!不知道你找到怎麼從黑米直接發佈書籤到blogspot的方法了沒?
這個要問葛力吧!他以前有做
http://www.hemidemi.com/tools/blog_bookmark_setting_blogtype
可是我沒有試過,可能新版的 blogspot 部落格會不行吧!
對啊就是因為新版的不行,所以讓人好頭痛。又不知道要去哪裡找到blogspot的xpml(是這樣寫?)
豬小草,來看看這個吧!
http://code.google.com/apis/gdata/blogger.html
如果葛力沒有時間寫,也可以幫忙他寫啊!去讀出黑米的Feed 然後用上面這些 API 自己塞到 blogspot.com 的部落格
什麼意思?完全聽不懂。。。
基本上這是我跟葛力之間的外星語,地球人是聽不懂的,台灣的政治人物也是外星人,但我們不同族,所以雖然他們聽不懂,但都會發表沉長的批評言論。而我們這一族外星人(克隆黑米星系人)發表的言論都是很簡短的。
Suggested ages 5 to 10 Kate Kate The Fashion Plate, "I Have To Be Me" is the first in a series about an aspiring tween aged fashion designer in New York City. ghd hair Handbags are one of the wisest investments a woman can make for her wardrobe. ghd straighteners cheap The spacious 22,000-square-foot restaurant and party bar encompasses two levels and an expansive outdoor patio overlooking the steamy Sirens of TI show and one of the busiest stretches of the Las Vegas Strip. north face jackets Their motto is they make designs for women with "way too much attitude." A.. north face sale As a half-man/half-bear I am uniquely qualified for such a dual task, though I feel obliged to point out to you, my Snarky audience, that this particular article was written for bears by a (half-)bear.
Posted on February 27 2012 by admin. http://www.oneghdhair.com There is a good reason that these are referred to as foundation garments. ghd hair straighteners This look can be easily incorporated into your look. http://www.verynorthface.com They tells stories of the love that they have given and received, the success that they have achieved and the challenges that they have overcome to get to where they are today.. http://www.manyghdhair.com Patrick and Roxanne Devaney, owners of The Sherlock Holmes Pubs (three locations), the Rose Crown Pub and Devaney's Irish Pub, have embarked on a fresh, new endeavor called Moriarty's Bistro | Wine Bar.
I mean, after all, isn Valley where mall shopping was raised to an art form? It wasn until I moved away from home and made my first trek to Union Square in San Francisco that I discovered what a true department store could be like. http://www.morenorthface.com You find it presents feeling of stability. ugg canada When there is a selected Chanel carrier that you want, that is from the price range, then the initial thing that you ought to do would be to go and appearance on-line because of it. http://www.wellnorthface.com Though it is called bogus jewellery but in fact it a genuine replica on the one of a kind kinds obtaining superb filling out. ghd online Comment Interior Design Sketch Portfolio by Riño Karlo Redo i kinda backed away a little when you did that 1-strike cut at 2:49.
buy tramadol buy tramadol order cheap tramadol online - cheap 100mg tramadol
buy xanax online without rx xanax 420chan - xanax side effects overdose
tramadol 50 mg buy tramadol for dogs - where to buy tramadol usa
how to buy xanax online legally xanax side effects joint pain - xanax pills wiki
buy tramadol online tramadol 50 mg online pharmacy - tramadol overdose how much is fatal
buy cheap tramadol cloridrato de tramadol 100mg/2ml - tramadol withdrawal exercise
buy tramadol online no prescription tramadol dosage rls - buy tramadol 180 online
buy tramadol online what does 100 mg tramadol look like - buy tramadol no prescription
xanax alprazolam generic xanax ( by gador - alplax) - xanax withdrawal benadryl
buy tramadol online tramadol 50mg 627 - buy tramadol online cod no prescription
buy tramadol overnight cod buy tramadol online forum - buy tramadol using mastercard
alprazolam drug xanax 1 mg recreational - drug abuse of xanax
generic xanax how to xanax online - xanax dosage vs valium
carisoprodol 350 mg carisoprodol prodrug - soma or carisoprodol
buy tramadol online tramadol hcl tab 50mg side effects - tramadol dosage equivalent
order tramadol no prescription can i buy tramadol over the counter usa - tramadol hydrochloride 100mg used
buy tramadol online tramadol hcl 50 mg espanol - can you buy tramadol in greece
generic xanax buy xanax legally - xanax youtube
carisoprodol 350 mg buy carisoprodol usa - do drug tests test carisoprodol
buy tramadol online tramadol side effects high - buy tramadol australia
generic xanax xanax withdrawal heart rate - long does xanax 1mg work
buy tramadol online tramadol 50 mg for headaches - ultram-tramadol.us
carisoprodol 350 mg what is soma carisoprodol tablets - carisoprodol in drug test
buy tramadol online can take tramadol high blood pressure - tramadol 50 mg street price
buy tramadol online generic for tramadol hcl - tramadol 50 mg bula
buy cialis cheap cialis online best price - ho comprato cialis online
buy tramadol online tramadol 100 mg bijsluiter - g e tramadol hcl
xanax online does xanax show up parole drug test - xanax bars withdrawals
xanax online xanax side effects in children - xanax 2mg bars yellow
cialis online cialis daily 2.5 - cialis online satis
cialis online cialis daily risks - generic cialis date
best buy tramadol tramadol overnight delivery - buy tramadol online mastercard
buy tramadol side effects for tramadol 50mg - tramadol 50 mg in dogs
buy tramadol can you buy tramadol over counter us - buy tramadol no prescription 100 mg
buy tramadol online tramadol 600 mg daily - buy tramadol london
http://buytramadolonlinecool.com/#30807 seizure after overdose tramadol - tramadol 600mg
order tramadol no prescription can you buy tramadol online - tramadol hcl 37.5-3 tab myla
learn how to buy tramdadol buy tramadol in usa - tramadol withdrawal upset stomach
buy tramadol online best way buy tramadol online - tramadol cream
ways to buy ativan online ativan side effects 1 mg - ativan overdose symptoms
http://buytramadolonlinecool.com/#56411 tramadol withdrawal wellbutrin - tramadol for dogs best price
buy tramadol in florida tramadol overdose help - buy tramadol cod shipping
cheap ativan online ativan manufacturer - lorazepam 1 mg overdose
http://reidmoody.com/#36921 ativan overdose and treatment - ativan good alcohol withdrawal
buy tramadol online tramadol for dogs and humans the same - what does tramadol 50 mg do to you
buy tramadol online no prescription cod long does tramadol overdose take - tramadol online cod payment
buy tramadol saturday delivery tramadol hcl side effects - buy tramadol online pharmacy
buy tramadol online tramadol hcl 50 mg canine - tramadol renal failure
buy tramadol online high on tramadol hcl - tramadol yahoo
pharmacie cialis cialis cialis paris
buy tramadol overnight delivery buy tramadol cheap - cheap tramadolonline
I got the new the king casino no deposit bonus【Malaysia】
【 바카라 William】pinterest wooricasinos.info in 2021, the 출장안마 king communitykhabar casino no deposit bonus,【WG98.vip】⚡,taylorlancer,taylorlancer,golfking. poormansguidetocasinogambling.com
給予迴響