推 popcorny:所以你的問題不就是不知道怎麼取得twitter id.. right? 12/07 11:09
→ alan0541:我看看... 12/07 15:21
→ alan0541:不知道該怎麼用... 12/07 15:52
請參考sign-in-with-twitter範例
https://github.com/yusuke/sign-in-with-twitter
檔案:sign-in-with-twitter/src/main/webapp/index.jsp
<tag:loggedin>
<h1>Welcome ${twitter.screenName} (${twitter.id})</h1>
<form action="./post" method="post">
<textarea cols="80" rows="2" name="text"></textarea>
<input type="submit" name="post" value="update"/>
</form>
<a href="./logout">logout</a>
</tag:loggedin>
上面紅色標示的地方即為twitter id
這個index.jsp有用到Tag File與EL,對剛接觸JSP的朋友應該稍微有點吃力
Scriptlet的版本請參考 https://gist.github.com/4232986
附帶一提,這個範例在session的處理上沒有做得很好
如果連 http://localhost/sign-in-with-twitter/index.jsp 發生Exception時
請改連 http://localhost/sign-in-with-twitter/signin
若是signin也發生錯誤時,請檢查consumerKey、consumerSecret與callback網址
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.193.183.7
推 alan0541:萬分感謝! 12/10 10:46
推 alan0541:如果使用Scriptlet的範例,session怎麼取都是NULL? 12/10 11:30
推 alan0541:有人可以回答我嗎= =? 12/11 10:28
→ phstudy:你怎麼確認session是null的? 12/11 10:55
→ phstudy:你signin的servlet有配置成功嗎? 12/11 10:58
→ phstudy:連進signin後,session.getAttribute("twitter")不會是null 12/11 11:01
→ alan0541:原來如此,我再試試! 12/11 12:08
推 alan0541:可以了,真是太感謝您了!!!!!! 12/11 13:48
推 alan0541:其實只是我自己使用錯函數而已... 12/12 10:31