Oct 21~24, 2023【晚秋の贅沢な山旅 PART①】從名古屋搭車至長野|在北阿爾卑斯山麓的文藝小鎮信濃大町散步、品嚐美味的炸豬排定食和咖啡

圖片
今年10月下旬,趁著深秋季節,請了兩天特休假,飛往日本中部北陸地區,探訪兩處幾年前就想去的地方。其中一處是位於 新潟縣 和 長野縣 交界處的日本百名山【 雨飾山(Mt. Amakazari) 】,10月中下旬的紅葉全盛期,是造訪這座 日本百名山 的最佳時間點,且因爲海拔高度只有兩千公尺左右,相比三千公尺級的 北阿爾卑斯山脈 ,這裡的積雪時間略晚一些。即使到了10月下旬,只要沒有強烈冷氣團,沒有雪季登山裝備也還是能夠登頂。 另一處則是少為人知的 秋季限定路線 ,黑部峽谷【 下ノ廊下 】(下之廊下),這個地方除非是登山客,不然連一般日本人都不太普遍聽過。 下之廊下 位於 黑部大峽谷 的北部地區,因為靠近 日北海 ,冬季這裡是豪雪地帶,只有從每年9月下旬登山道的積雪完全融化後,到11月上旬左右,山區再次降雪之前,大約一個月左右的時間可以通行。 據聞2022年因融雪較慢,能通行的時間只有短短兩週,而今年則是融雪較早,9月中旬就全面開通了。前陣子9月來日本爬山時,原本就有計畫要來這裡,不過後來因為一些原因,就提前返國了。最終等到10月下旬的深秋,也盼到了連續幾日都是好天氣的日子,終於如願前來造訪! 每年10月下旬至11月上旬,是 下ノ廊下 的紅葉最盛期,也是登山客最多、最混雜的時期。其壯闊的峽谷絕景、險峻的斷崖峭壁、遠方覆上初雪的山岳景致、迷人的三段紅葉、還有途中有著被稱為「 秘湯中的秘湯 」的【 阿曾原溫泉 】,加上 一年之中只有極短時間可通行的條件 ,使得黑部峽谷【 下ノ廊下 】成為喜愛山岳之人無不嚮往造訪的山岳秘境。 黑部峽谷自古就是人跡罕至的秘境而廣為人知,江戶時代也因加賀藩的國境警備和森林管理而禁止進入,僅黑部奧山廻御用之役人在此巡邏。明治時代以後對外開放,黑部也成為眾多登山家的目標。其中,冠松次郎因致力探索峽谷而有「黑部之父」的稱號。 黑部峽谷以黑部湖(黑部水壩)為境,可分為 下之廊下 、 上之廊下 ,以及 奧之廊下 。「廊下」是山岳用語,意指「 絕壁之間的深谷 」,而「下之廊下」相當於黑部峽谷的心臟地帶,花崗岩岩壁間的激流從下游起形成白龍峽、十字峽、S字峽等景點。 由於行走於距離河面數十至上百公尺的斷崖峭壁間,許多區間寬度又十分窄小,是有點危險的路線, 每年都有人在這裡不慎摔死 (今年也不例外)。 日本國土地理院地圖(下之廊下) 據說今年秋天日本的下雨天數特別多

Connect to the Foursquare API via OAuth in your Rails application

OAuth is an open authentication protocol that allows secure API communication without the necessity of continually passing a username and password with each request. The idea for OAuth was conceived in 2006 by a group of individuals working on the Twitter implementation of OpenID. 

After reviewing both OpenID and other existing industry practices, such as Amazon Web Services API and Flickr API, it was decided that a proposal should be written for a new open protocol for application authentication.

OAuth has been widely adopted among major web services. Twitter, not only implementing OAuth as its primary API authentication method, but using it as the basis for its “Sign in with Twitter” service. Today, you’ll also find the protocol used by Facebook, Google, Yahoo, LinkedIn, and many others.

Foursquare is a new and rapidly growing social utility whose potential for mash-ups with other applications is limited only by one’s own imagination. The Foursquare platform implements the OAuth 2.0 standard, so users can authorize applications to access Foursquare resources on their behalf without revealing their passwords or other credentials to those applications. The foursquare API gives you access to all of the data used by the foursquare mobile applications, and, in some cases, even more.



I have been experimenting with the Foursquare API for a few days now, and I wanted to show you how you can implement use Foursquare in your Rails application using OAuth 2.0 (This is a very simple Rails application that connects to the Foursquare API using Quimby [http://github.com/groupme/quimby]). It is working fine as I'm using Rails 2.3.8 on ruby 1.8.7 and it also work with Rails 3!

I'm going to just give you the concept for this post. If you have no prior experience with Ruby or you are new to Rails, as you read this post, don't get use these code directly, it will not work for your blank Rails application.

Below is a general overview for an OAuth connection: 
1.Send request to target website for token, with the server's client_id & secret_id 
2.Redirect user to authorize page with token (and callback url)
3.After user confirm, user will be redirect to the callback page with a access_token
4.Save the access_token, and free to call target server for user data.


You will need a Foursquare account to obtain your key and secret in the first place. Visit https://foursquare.com/oauth to register your Rails application and obtaining your API credentials, where you need to provide an app name (ex: Railscode), a website url (ex: http://localhost:3000) and a callback URL (ex: http://localhost:3000/fsq_callback).  It’s a free signup, and if you wish to work on the API I’m sure you’ve already had an interest in the application! After registration, you should see something like this:



Copy your Foursquare App Client ID & Client Secret and paste it into your environment.rb or maybe config_foursquare.yml. The callback URL is the location your users will be sent after they authenticate on Foursquare’s site.

Next run rails script to generate a migration file:
$ script/generate migration add_foursquare_to_users



And we have to install the following ruby gems:



We need to be able to intercept this redirect, capture the token, and store it so we can begin interacting with Foursquare. Add the following method to the application controller:



Next we need to write a callback method in the fsq_oauth_controller.rb. Once we’ve retrieved the code from the Foursquare server, we can exchange it for an access token.



Add the following line in the routes.rb:



In order to retrieve an access token, we need to redirect the user to the Foursquare authorization URL (More info can be found on https://developer.foursquare.com/docs/oauth.html). we can add the foursquare connect button in the view page:



When pressing the login button, you can login with your Foursquare credentials!


Now that the app has an access token, we can launch our main activity and start interacting with Foursquare.

This has been a basic look into getting started with Foursquare’s API. OAuth is a very powerful open protocol for connecting into larger social communities. It offers the most secure solutions for both users and web masters. The Foursquare Developers center is an amazing tool for newbies.Scour the resources and look up and function calls you may be interested in working with. Similarly the official OAuth website has some terrific readings outlining the purpose and practical solutions for the protocol.

熱門文章

[轉載] 洛克菲勒寫給兒子的38封信(全文)

May 2023【台中南屯】地雷店食記|森鐵板燒|用餐體驗差,價格超貴卻豪無價值。小心別踩雷!!!

Jun 24~25, 2022【南橫三星】庫哈諾辛山+【南臺首嶽】關山(進涇橋登山口)|2天1夜野營登山

September, 2012 白姑大山二天一夜~其實沒那麼累,只是路途遙遠

Sep, 2021【苗栗南庄】蓬萊林道Off Road小試|雨後很爛很濕滑|二傳低底盤車勿輕易嘗試

Sep, 2023【桃園龍潭】輕鬆登頂石門山欣賞石門水庫湖光山色|景春步道+小竹坑古道O型路線午後健行

Oct 21~24, 2023【晚秋の贅沢な山旅 PART②】黒部峽谷♡下之廊下|日本北阿爾卑斯山秘境健行+野營+秘湯溫泉 DAY 1(黒部水壩〜下之廊下〜阿曾原溫泉)

Nov 20, 2022【新北烏來】信賢步道健行~輕鬆好走的生態步道,還可順遊內洞森林遊樂區

Feb 2023【台中和平】裡冷林道Off Road單車野營~順登谷關七雄之首八仙山!單車+野營+登山,三個願望一次滿足

【美國加州】加州一號公路自駕遊~Half Moon Bay、17 Mile Drive、Bixby Greek Bridge、Big Sur、McWay Falls、Elephant Seal Rookery

文章列表

Contact

名稱

以電子郵件傳送 *

訊息 *