Sep 2024 晚夏的黑部源流4泊5日山旅 PART ①【溪流登攀&溫泉三昧】赤木沢~五郎沢~祖父沢遡行&雲ノ平~高天原~裏銀座縱走(旅途的開始)

圖片
今年晚夏的山旅,我前往了日本北阿爾卑斯山脈黑部源流域進行為期五天四夜的溪流登攀+登山縱走行程。黑部川源流一帶的山域,雖然過去幾年已造訪過多次,不過這回是第一次在日本進行溪流登攀(日本叫「 沢登り 」),而且是在我特愛的黑部川流域,讓我對黑部源流域有了更進一步的認識。 此行也順路造訪了五年前就計畫要去,但是因爲颱風而沒能去成的「 雲ノ平 」,以及有「 日本第一遠的溫泉 」之稱的秘湯「 高天原溫泉 」泡湯。然後還走了去年因為天氣惡劣而沒能走的「 裏銀座縱走路線 」下山,完成這趟縱橫黑部源流域,總距離50幾公里的溪流登攀和登山旅行。 黑部川 (日語:黒部川/くろべがわ)是日本富山縣東部的一級河川,為黑部川水系的本流,它被列為富山縣的七大河流之一,其他六條河流分別是片貝川、早月川、常願寺川、神通川、莊川和小矢部川。 黑部川 大部分蜿蜒於深山內,形成十分陡峭的黑部峽谷,如果想親身感受黑部峽谷的壯闊,走一趟 下ノ廊下 和 水平步道 ,絕對是畢生難忘的體驗。 下圖為黑部川水系流域的示意圖,從海拔2924米的 鷲羽岳 降下的的最初的一滴水,流經 奧ノ廊下 、 上ノ廊下 、 下ノ廊下 ,並匯聚了黑部山區眾多支流的溪水後,向北奔流而下,然後流入富山灣,最後進入日本海。 下圖是這趟山旅所進行的溪流登攀(沢登り)的區域,包括 赤木沢 、 五郎沢 、 祖父沢 等黑部川支流,主要位於黑部川的源頭,尤其是赤木沢,更有著「 日本第一美溪 」之稱號。 黑部源流…這幾個字對登山者來說有著特殊的魔力。人跡罕至的秘境,峽谷綿延的 上ノ廊下 ,激流沖刷岩石的 下ノ廊下 ,源頭的雲ノ平瑞士庭園等。在這黑部源流的一隅,一條溫柔的小溪緩緩流入。赤木沢與黑部川本流交匯處的絕美景色,展現了大自然鬼斧神工的美麗,在陽光照耀下的溪流和深潭,呈現出豐富的色彩變化,其美景宛如天國一般。 下圖是我這趟五天四夜的山旅,所行經過的整個路線(使用 YAMAP 紀錄),從富山縣的 折立登山口 入山,溯行黑部源流域的多個溪流(黑部川上游的支流),並順訪 雲ノ平 和 高天原溫泉 後,再走 裏銀座縱走路 ,由高瀨湖下山,總距離約53.6公里(不過在 Sports Tracker 上面的紀錄卻是63.3公里,不知道哪個才是正確的)。 這趟山旅的途中,依序住宿 藥師沢小屋 、 黑部五郎小屋 、 雲ノ平山莊 、 水晶小屋 ,這些都是以前沒有住過...

Connect LinkedIn Account into your Rails Application with Authlogic and OAuth

LinkedIn launched its new API in November 2009, allowing any developer brave enough to implement OAuth to integrate with one of the largest social networks around. Seeking an opportunity to really understand OAuth more fully and play around with the LinkedIn API at the same time, I created the LinkedIn connect sample code.

This is a sample Ruby on Rails tutorial to demonstrate how you can use the LinkedIn API to authenticate users and pull their profile data into your own website.


GETTING STARTED


Before you can use the LinkedIn API, you'll need to set up your API keys.

Getting Started with the LinkedIn API


1. Where do I begin? Start by navigating to http://developer.linkedin.com. This is Linkedin developer portal where you can read API documentation, collaborate with other developers, and keep abreast of changes to the LinkedIn API. From here, click on “LinkedIn APIs.”

2. Now click on “Request an API Key”

3. After logging in, you’re now presented with an opportunity. You can create as many API keys as you like, one for each application that you create. Let’s get started.


4. This isn’t as complicated as it looks. Let’s look closely.
Application Developers: This is a list of your LinkedIn Connections that will receive network updates published by your application and is used only while it is in development mode. You need to be connected to any LinkedIn member that you want to put on this whitelist. Interface Language: Your application is provided in one or more languages to end users. Let us know what those languages are so we can better support you in the future. Programming Tools: Knowing what kind of programming languages and tools you use to develop your application lets us know what languages and environments are most important for us to support. Just a few more fields to go over!

5. Ready to get your API keys? When you’re done, click “Add Application”
Contact Info: Tell us how to get in contact with you should we have a question about or there is a problem with your application.
OAuth Redirect URL: If you have a static location that should always be used for your OAuth callbacks, you can specify it here. It is recommended that you use the oauth_callback parameter in the appropriate requests instead.
Agreement Language: If you’d like to force the login screen to appear in one of the languages LinkedIn supports, you can set that here. It is recommended to leave the setting at “Browser Locale Setting.”
Terms of Service/CAPTCHA: Please do read our API Terms of Use. You cannot create an API key without agreeing to our terms. You’ve likely seen a CAPTCHA before, and it needs little explanation.



6. You’ve got your API keys. What’s next?
The LinkedIn Developer Network is where you’ll find guidelines, documentation, and growing community of developers.


RUBY GEM INSTALLATION


First you need to upgrade your Rails VERSION to 2.3.x, and install the required Ruby Gems below:

1. Setup and use Authlogic

$ sudo gem install authlogic

2. Install OAuth and Authlogic_Oauth

$ sudo gem install oauth
$ sudo gem install authlogic-oauth

3. Install other required Ruby gems

$ sudo gem install json
$ sudo gem install crack

Or for older version of Rails, you can install it as a plugin:

$ script/plugin install git://github.com/binarylogic/authlogic.git
$ script/plugin install git://github.com/jrallison/authlogic_oauth.git

* Authlogic at Github:http://github.com/binarylogic/authlogic
* Authlogic Example: http://github.com/binarylogic/authlogic_example


SETUP API KEY IN YOUR APP


Create load_linkedin_config.rb in #{RAILS_ROOT}/config/initializers directory

Create linkedin_config.yml in #{RAILS_ROOT}/config directory



DATABASE MIGRATION


1. Make some changes to user table in your database:

$ script/generate migration AddLinkedinConnectToUsers

2. Create Position,Education and Connection model:

$ script/generate model position

$ script/generate model education

$ script/generate model connection


3. Modify the User model, add the content below to the #{RAILS_ROOT}/app/models/user.rb:

The private method "populate_oauth_user", which is called before user record created, and is used to fetch profile info (name, headline, industry, profile pic, public url, summary, specialties, web urls) in LinkedIn.com, and save these info to your user record. The other private method "populate_child_models", which is called after user record created, and which will save past position info (companies, job titles, durations, descriptions), education info (schools, degrees, field of study, dates, etc) and connections info (names, industries, headlines, profile pics) for user.

4. Modify the Connection model, add the contents below to the #{RAILS_ROOT}/app/models/connection.rb:

5. Modify the Education model, add the content below to the #{RAILS_ROOT}/app/models/education.rb:

6. Modify the Position model, add the content below to the #{RAILS_ROOT}/app/models/position.rb:

7. Create UserSession model, and define the oauth_consumer class method on your UserSession model:


CONTROLLER METHOD


You only need to save your objects this way if you want the user to authenticate with their OAuth provider.

That being said, you probably want to do this in your controllers. You should do this for BOTH your User objects and UserSession objects (assuming you are authenticating users). It should look something like this:

You should save your @user objects this way as well, because you also want the user to authenticate with OAuth.

In my case, I have to integrating the LinkedIn OAuth Sign in feature to my current Rails project, so I changed the "Create" method in my UsersController like this way:

When the user click on the LinkedIn Login button and we can't find the oauth_token and oauth_secret in the database, the user will be redirect to signup page with "linkedin_user" parameter. After fill in the fields, they will be redirect to LinkedIn authentication page, then user record will be created. If we can find the oauth_token and oauth_secret in the database, the user will be login to the site.



ADD REGISTER BUTTON


You can simply use the "oauth_register_button" helper method to add LinkedIn register buttons to your views, like this:

Now add some style in your CSS file for LinkedIn button:



NEXT STEPS


Now we have user's LinkedIn data saved in the database, so you can write some codes to show the user's LinkedIn profile data (such as Username, Headline, Location, Education, Position, Websites, Skills, Experience, Connections) in the website.

You may want to add methods to update profile info on each login or update request. Or pull status updates, specialties, and current position for connection.

If you're interested in learning more about LinkedIn and OAuth, I encourage you to checkout Taylor Singletary's presentation LinkedIn OAuth: Zero to Hero.

熱門文章

May 2023【雲林古坑】 負離子濃度達都市40倍/漫步木馬古道/順訪雲嶺之丘/山合苑喝咖啡/秋田犬

Jun 2025【苗栗獅潭】苗栗百大必訪步道|小百岳仙山|靈洞宮起登,雲霧繚繞,仙氣滿滿

2019.10.9~13【令和元年の紅葉の山旅へ PART①】秋の贅沢、黒部川の源流へ北アルプス深部を縦走5日間!Day0、Day1(前泊、折立~藥師岳山莊)

Jun 2025【桃園蘆竹】全台百大必訪步道|羊稠森林步道|秋田犬散步|羊稠步道甲蟲季即將登場

Sep 26, 2023【夢と浪漫 伊藤新道①】探訪日本北阿爾卑斯山脈黑部源流域一條封閉了40年的古道「伊藤新道」―Day1―高瀨溪谷健行・從七倉登山口前往湯俣溫泉晴嵐莊

Jan 2025【苗栗泰安】泰安警光山莊泡湯&彰化CP值極高的日本料理|沐藏料理所X海龍王|彰化板前料理 ♨️🍁🥢🍲

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

Jun, 2023【花蓮秀林】中橫四辣之中辣|屏風山|兩天一夜野營登山(新登山口台8線111.2K起登)

Jun 2025【彰化員林】月光山舍土雞料理景觀餐廳(寵物友善餐廳)|員林最夯休閒步道|藤山步道散步

Jun 2025【新北林口】觀音山硬漢嶺步道O型散步(龍女岩、硬漢嶺、鷹仔尖)

文章列表

Contact

名稱

以電子郵件傳送 *

訊息 *