3

我正在做一个 Twitter Mac OS X 应用程序,需要使用 OAuth1.0。在请求 oauth/access_token 接口时,是否可以oauth_callback为此目的使用该参数?

换句话说,如何在 Max OS X 上从浏览器打开应用程序?

4

1 回答 1

9

答案很明显:注册自定义 URL 方案

http://techblog.amphora-research.com/2010/03/registering-url-handlers-in-macos-x-cocoa-apps/

我的意思是说:

 1. Register the "twittercallbackformyapp://"
    scheme using the link above
 2. Set this callback in the 'access_token'
    HTTP request (oauth_callback parameter)
 3. Write the routine (handleOpenURL) to handle
    the 'twittercallbackformyapp://oauth_access_token=...&oauth_token_secret=...'
    which will be called after you register the handler

关于 oauth 的许多问题都在这里解决了:http ://code.google.com/p/twitcurl/

上面的库使用 curl。您可以使用 Cocoa 原生网络 API。

附言

下面是关于如何注册 URL 处理程序的另一个描述:

http://mobiledevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html

它适用于 iPhone,但对于 Mac,模式是相同的:将 URL 添加到应用程序的 .plist 文件中。

于 2012-05-02T08:00:55.627 回答