【美國加州 Yosemite National Park】優勝美地國家公園健行之一.迷人的秋日美景。飽覽山谷與Vernal Falls、Nevada Falls兩大瀑布

圖片
「一生必去」這4個字的最高等級用語,絕對可以用來形容美國加州的「優勝美地國家公園」(Yosemite National Park),相信沒有人會反對。因為它在世界上的地位,彷彿就是「大自然的大教堂」。
優勝美地國家公園(Yosemite National Park),是美國國家公園內極為閃耀的一顆明珠,地處加州東北部,內華達山脈的西麓,曾是印第安原住民阿瓦尼奇人(Ahwahneechee)的故鄉。公園的範圍橫跨加州中西部圖奧勒米縣(Tuolumne)、馬里波薩縣(Mariposa)和馬德拉縣(Madera)。優勝美地國家公園於於1984年被納入聯合國教科文組織(UNESCO)世界遺產,每年吸引4百萬來自世界各地的遊客前來觀光。
優勝美地國家公園內,有超過95%的土地被指定為原生地域(wilderness),為了要保護公園的原貌,美國總統林肯於1864年6月30日,將優勝美地谷蝴蝶林(Mariposa)內的美洲衫巨木林,設為美國的第一座州立公園。並且在「國家公園之父」約翰•繆爾(John Muir,1838~1914)這位作家、科學家、保育先知的倡議之下,於1890年成為第二座國家公園。它幾乎是全美甚至全球最受歡迎的國家公園。
公園內除了有四面絕壁的優勝美地山谷,還有充滿高山美景的圖奧勒米牧場,自然風光令人歎為觀止。而它的美和大遠遠超過一般人所暸解,公園的佔地面積超過1,169平方英哩/284,899 公頃,而其中最多遊客造訪的的優勝美地谷(Yosemite Valley),只佔了整個公園不到1%的面積。優勝美地國家公園主要有四大景區,呈F型分佈,分別是優勝美地谷(Yosemite Valley)、山頂的冰川點(Gracier Point)、北側的第奧嘉(Tioga Pass)以及南端的瓦沃納(Wawona)景區。這次的優勝美地之旅,只有北側的第奧嘉景區沒有造訪,那裡就留待下次不同季節再去造訪吧!

優勝美地山谷在上一次冰河時期被冰川覆蓋,山谷呈U字型,兩旁峭壁上到處可見由冰川切削過的痕跡,其中最有名的就是半圓頂(Half Dome),這顆巨岩是冰河時期所形成的,峰頂海拔2,693公尺,歷時8,700萬年,在地質與歷史上他就是個不折不扣的巨人。只要你在優勝美地國家公園內,走到比較高的地點,幾乎從任何地方,都可以看到它的身影,據說 North Face 品牌 logo 的…

FbGraph + OmniAuth + Facebook Graph API on Rails application

OAuth is often described as a 'valet key for the web'. In the same way as a valet key gives restricted access to a car, allowing the valet to drive it but not open the trunk or glovebox, OAuth allows a client application restricted access to your data at a resource server via tokens issued by an authorization server in response to your access grant.

Facebook Platform uses the OAuth 2.0 protocol for authentication and authorization. Suppose your Rails application allows users to share content with their Facebook friends. To support this, a connection needs to be established between a user's local account and her Facebook account. Once established, a Facebook instance can be obtained and used to post content to the user's wall. The basic idea is to store the access_token during an OAuth2 login process and later on use the token to fetch more data.

The last days I was working on letting user sign-up/sign-in using Facebook account. I'm planning to integrate some social features into my ongoing Rails project. Previously I was working with Facebooker, an awesome Rails plugin that did a great job for my previous project, however it seemed not support the latest Facebook Graph API. Thought I found a new solution.

OmniAuth is an open source project which provides support for many of the main providers out there: twitter, facebook, foursquare, and many more. In addition, OmniAuth is designed in such a way that it is very easy to implement custom strategies---interchangable logic which encapsulates the steps required to successfully authenticate with an Oauth2 provider.

OmniAuth relies on the request and callback sequence as defined in OAuth2 specification. OmniAuth extracts away a lot of the complexity of working with OAuth, so we can skip all of that information and focus on just what we need to. The diagram below depicts how OmniAuth handles the request and callback sequence:


The request phase of the OAuth dance typically redirects to a providers website which prompts the user to enter their credentials with the provider calling back to Omniauth with a success or failure message.

There is a couple of great screencasts on how to integrate Omniauth to Devise using Rails 3 and allow Facebook, Twitter, etc. authentications. In this post, I'm going to show you how to connect to the Facebook platform using FbGraph along with Omniauth to retrieve a list of records and post message to the facebook wall via its Graph API. For this example, I'm using Rails 2.3.8 on my Mac. But I strongly encourage you to start with Rails 3.

First, we would need a migration to store a permanent Facebook token for offline access:
$ script/generate migration AddFacebookTokenToUsers


Add the following to your config/environment.rb

Next, in your initializer, usually config/initializer/omniauth.rb, request additional permissions, we need to tell Omniauth to retrieve more Facebook permissions in order to have offline access, Wall, etc. You can define the ones you need from Facebook permissions API pages, but here is my setting:

If you get this error message when you're trying to run your Rails server: 
WARNING: Nokogiri was built against LibXML version 2.7.7, but has dynamically loaded 2.7.8
The problem was most likely bad library management, if you don't have libxml2 in the Cellar directory on OSX, you can install it to this using homebrew:


Now, lets get to the application code changes. In the application controller we define the facebook_user like this:


In the routes.rb we add following routes:


Next, edit your fb_oauth_controller.rb add the callback method:


Callback is the action that is called after the authorization. The access_token is not restricted with time unless Facebook changes their policy and make them expire after a particular period of time, and is used later for interacting with Facebook.. To understand how it all works, read about Facebook permissions, the Graph API. The /auth/facebook url is invoked first. This redirects the user to Facebook where the user gets the permission prompt, to allow your application to access the users information. If everything works you should have the full authentication workflow going!



You can also use this URL to get a permanent access_token:


Facebook uses the OAuth 2.0 protocol for user authentication and application authorization. Following are the steps required to obtain an access token:

(a) Redirect the user to https://graph.facebook.com/oauth/authorize and pass the application id and post authorize callback URL as parameters to this API.
(b) User enters their credential in the above Facebook URL and after successfully authorizing the application, Facebook would redirect the user to the authorize callback url along with a verification string in the argument code, which can be exchanged for an OAuth access token.
(c) Generate an access token using the above verification code by fetching https://graph.facebook.com/oauth/access_token

Once the access token is obtained, all further communications to Facebook will only require this token instead of the user’s credentials. 


You can modify the callback method to integrate Facebook connect with your authentication system (Allow your users to sign up/sign in with their Facebook account). See the example below:


Now the application retrieves email and also you have an access to Facebook Graph API. For instance, to post something on Facebook wall you can:




Enjoy! hope this helps you :)


熱門文章

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

2013.5.25~26【新阿溪縱走】眠月線鐵道線探勘。順登松山、萬歲山、小笠原山、對高岳

斗六市70年老店 山姆紅燒羊肉爐

2018, Jan 14【高雄】旗津半日遊&不老溫泉度假村泡湯&南橫公路梅山口賞梅花

2012 アルプスの夏:飛騨・北阿爾卑斯山脈南部の焼岳/槍・穂高連峰/表銀座単独縦走記錄。Day5 穗高岳山莊~涸沢岳~北穂高岳~飛騨泣き~A沢のコル~長谷川ピーク~大キレット~南岳小屋

【南投信義】玉山國家公園散步★塔塔加六山之三:鹿林山、麟趾山、鹿林前山&八通關古道之雲龍瀑布健行

【美國加州 Yosemite National Park】優勝美地國家公園健行之一.迷人的秋日美景。飽覽山谷與Vernal Falls、Nevada Falls兩大瀑布

文章列表

聯絡我

名稱

以電子郵件傳送 *

訊息 *