gpt4 book ai didi

oauth - 如何在 Mac OS X 上从浏览器打开应用程序?

转载 作者:行者123 更新时间:2023-12-01 09:36:46 24 4
gpt4 key购买 nike

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

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

最佳答案

答案很明显:注册自定义 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 文件中。

关于oauth - 如何在 Mac OS X 上从浏览器打开应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10408801/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com