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

圖片
今天是這趟四天三夜秋季山旅的第二天,昨天在信濃大町悠閒度過了半天,今天終於要進入黑部峽谷山區了。原本是預計早上6點15分,要從信濃大町車站前,乘坐第一班巴士前往 扇沢 ,但是旅館客房太溫暖,不小心睡過頭,等到自然醒時,看了手機已經早上6點了。 這時就算再怎麼快速收拾背包衝到車站也趕不上6點15分的巴士了。雖然還有下一班巴士可以搭,但是今天的路程有點遠,得走上20公里,加上紅葉季節,如果太晚抵達露營場,可能會找不到位置紮營,所以我想還是儘早出發比較好。幸好車站前有計程車可以利用,只是必須多花幾千塊日幣消災就是了。 在觀光季節,最早一班由 扇沢 開往 黒部ダム ( 黑部水壩 )的巴士是早上7點30分發車,所以只要需抓個50分鐘的乘車跟買票時間,大概早上6點40分左右,從大町車站前搭上計程車就沒問題了。 洗漱完畢,整理好背包後,將房間鑰匙放回旅館櫃檯的籃子裡,然後走路到車站前面,叫一輛計程車前往 扇沢 (車資大約8000日幣上下)。走在路上可以看見遠處三千公尺級的高山,都已經覆上了新雪,預告著今年的雪季即將到來。 早上7點左右抵達 扇沢 ,買了一張前往 黑部水壩 的單程電氣巴士車票(1,800日幣),然後將登山計畫書投遞進箱子裡,走上二樓排隊等待搭車。果然不愧是紅葉季節,車站二樓裡面,整整四排的排隊區,已經排滿了登山客和觀光客。 扇沢 其實就是 立山黑部阿爾卑斯路線 的長野側起點,是觀光客很喜歡造訪的地方,只是一般觀光客不會曉得,站在黑部水壩頂部欣賞放水時,在那 日本規模第一 的水壩後方之溪谷深處,竟然隱藏著一條少為人知的登山步道。 相關參考連結 下ノ廊下を含む活動日記一覧(YAMAP) 登山ルート情報 - 阿曽原温泉小屋 立山黒部アルペンルート|公式サイト アルピコ交通|路線バス 扇沢線 くろよん(黒部ダム)ーその手に未来をー|関西電力 2021年の番組~最後の秘境・黒部源流紀行【小椋久美子が黒部川の“最初の一滴”を目指す旅】 【下の廊下】黒部峡谷の断崖絶壁を命懸けで歩く(前編) 【下の廊下】落ちたら終わりの絶景登山道(後編) 【テント泊登山】断崖絶壁30kmの道、黒部峡谷の歴史を歩く|旧日電歩道-下ノ廊下-水平歩道 黒部源流と大峡谷( 圖片來源 ) 雖然排隊人潮很多,但是早上7點半準時檢票上車,群眾也非常有秩序和效率的往前進,似乎連一點時間也沒有耽誤到就準時發車了,日...

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.

熱門文章

Mar 2025【桃園大溪】金面山(小百岳 No.021)、金山面山健行|阮家土雞城起登

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

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

Mar 12, 2022【重機一日遊】走北橫至宜蘭,經梨山、武嶺下埔里,再走台三線回桃園|16小時的半圈環島

Sep 2025【新北雙溪】蝙蝠山、苕谷瀑布、百二階古道O形|山頂有360度展望,但之後的路線蜘蛛絲有點多

2019, July 7~8【中國山東】老司機帶你攀登72位古代帝王曾登臨朝拜,以五嶽獨尊名揚天下的泰山(歷史典故+遊覽路線+遊記+照片)

2019 Aug 16~18【福建南平】中國世界遺產~福建武夷山遊記。登天遊峰、臨九曲溪、品大紅袍

日本の登山の歷史

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

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

文章列表

Contact

名稱

以電子郵件傳送 *

訊息 *