Mar 2026【隨筆】Clone a Meta Ray-ban Display glasses application|藍芽 L2CAP CoC 極致低延遲架構優化:實現 720p 智慧眼鏡流暢串流 👓(LIVE DEMO)

圖片
最近在做一些實驗性質的技術研究。記得去年短暫把玩過 2023 年底上市的第二代 Ray-Ban Meta 智能眼鏡,雖然它主要還是依賴智慧型手機作為算力中心,但我對它所使用的串流技術一直很感興趣——特別是聽說他們能用藍牙來做媒體串流。 去年曾經有同事隨口問我:「你覺得我們的眼鏡有可能做到跟他們一樣嗎?」我知道硬體規格擺在那裡,兩者本來就不是同一個量級,加上當時手頭上還有其他案子在忙,我就隨口開玩笑回說:「聽說 Meta 有兩百個人在搞那支眼鏡捏,如果我一個人就能幹贏他們兩百人,那我還待在這邊幹嘛?(笑)」 以前在業界討論競品時,常聽到一種很沒有建設性的說法:「他們不知道用了什麼黑科技」。坦白講,身為工程師,每次聽到某完全沒技術能力,只會在辦公室帶風向、玩小操作來確保自己既得利益的管理者把「黑科技」掛在嘴邊,當成不願深入理解技術的遮羞布,總覺得相當悲哀。一件理論上做得到的事情,外行人因為資訊差,既不懂原理又沒有實作驗證的能力,看什麼就都變成了黑科技。 某SW吃嘴哥有多會帶風向?光是我印象比較深刻、跟現任or前同事有關的的就有三件,約莫兩年多前,有次我私底下跟他討論公事(已經忘了討論啥了)時,那廝跟我說:『 唉~你看像S_A那些老人,我可不想要以後變成跟他們一樣 』(我心想:你不就只是個出嘴的貨色而已,在那看不起別人,啊你是又多高尚?)。 還有更久的事,疫情發生前以前,當年我們某處長J,離開公司跳巢到另一間陸資企業,且帶了一批人一起走,有次我跟嘴哥在公司用餐閒聊時,他說:『 有人說J大是現代吳三桂,你怎麼看? 』,我問他此話怎麼說?他說:『因為這個水果產品供應鏈目前清一色台廠,他把陸資引入,就像是吳三桂引清兵入關啊!』, 我知道那廝又在試圖帶風向散步閒話 ,於是我回他說:『商場不就是這樣嗎?我如果有夠多利益可拿,我也可以當吳三桂啊』(當年打開城門讓日本人進城的,已經是當今台灣幾大金控家族之一呢,吳三桂是又怎麼樣? 難不成傻傻的對你這種x咖忠誠會比較吃香?在你這雜碎底下不吭聲幫你做了N年的事,最後換來被出賣!啊你這貨是多清高??? ) 甚至連我們現任的某處長M,他也敢說閒話,一樣也是x年多前,當時M剛從另一間台廠空降來這邊不久,有次傍晚跟吃嘴哥外出用餐時,跟他在車內閒聊,聊著聊著他突然提起EE處長的私事,跟我說:『 ㄟ~你知道M他老婆已經_了嗎,然後M他現在跟那個與他同時...

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.

熱門文章

Dec 2024【苗栗泰安】水雲餐廳溫泉民宿♨️🥢⛰️|水雲三星之橫龍山~騰龍山健行|台中西嶼龍新鮮海鮮古早味餐廳

Nov 2026【台中東勢】大雪山的絕美香杉林步道|長壽山(肥崠山)、大棟山健行

Nov 2026【新北汐止】五指山古道O形(柯子林游泳池~友蚋山南峰~火燒坪山~柯子林山~金明山)

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

Nov 2024【陽明山溫泉】老字號「馬槽花藝村」的溫泉管線已恢復|在木造山景湯屋享受半露天硫磺溫泉

Mar 2026【隨筆】Clone a Meta Ray-ban Display glasses application|藍芽 L2CAP CoC 極致低延遲架構優化:實現 720p 智慧眼鏡流暢串流 👓(LIVE DEMO)

Nov 2026【台中東勢】從大雪山登山口起登,經屋我尾山,再從林道走個O型路線|中部最美林道當之無愧

Oct 2026【桃園復興】東眼山的午後O繞散步(從自導式步道上、東滿步道出)

Nov 2026【新北三芝】竿尾崙古道上竿尾崙山|全程爬升沒風景,但是山頂展望極佳

Nov 2026【桃園大溪】大艽芎古道上溪洲山、頭寮山|清幽好走、山頂展望極佳的健行路線

文章列表

Contact

名稱

以電子郵件傳送 *

訊息 *