【问题标题】:How to get RSS token for BitBucket by PHP CLI?如何通过 PHP CLI 获取 BitBucket 的 RSS 令牌?
【发布时间】:2015-10-04 05:08:40
【问题描述】:

我想获得有效链接https://bitbucket.org/{username}/rss/feed?token={token}(这是主要问题),然后在 CLI 中从该链接获得有效响应。

我知道我需要的参数,例如consumer_key, consumer_secret, request_token_url, authenticate_url, access_token_url.

我尝试使用StudioIbizz\OAuth\OAuth1,但似乎是为浏览器设计的,而不是为 CLI 设计的。

我试着跑了:

$this->OAuth = new \StudioIbizz\OAuth\OAuth1($this->consumer_key,$this->consumer_secret);

$requestToken = $this->OAuth->getRequestToken($this->request_token_url,$this->authenticate_url);

$token = $requestToken['oauth_token_secret'];

并将此 $token 粘贴到我的 RSS 链接,但随后我看到来自 Bitbucket 的消息 You must have read access to access the RSS feed.

我需要针对严重傻瓜的分步说明。


编辑:我试过这个:

$accessToken = $this->OAuth->getAccessToken($this->access_token_url,$requestToken['oauth_token_secret'],$requestToken['oauth_token']);

但后来我明白了:

Fatal error: Uncaught exception 'StudioIbizz\OAuth\OAuthException' with message 'Unexpected HTTP status #400'

【问题讨论】:

  • 我在 Bitbucket 文档中找不到任何关于您应该通过提要 URL 传递的令牌的信息,但我确信 OAuth 提供的令牌对您没有帮助。我在这里做了一些尝试,即使提供有效的 OAuth 令牌,您也需要登录。您想从提要中获得什么样的信息?也许您可以使用特定的 API 方法来获得它。

标签: php rss bitbucket


【解决方案1】:

我在官方文档中没有看到任何与此相关的功能。也许该功能不存在。 欲了解更多信息,您可以使用此链接:

https://confluence.atlassian.com/bitbucket/use-the-bitbucket-cloud-rest-apis-222724129.html

【讨论】:

    【解决方案2】:

    您可以将 stevenmaguire 的 Bitbucket OAuth 2.0 support 用于 PHP 联赛的 OAuth 2.0 Client

    $provider = new Stevenmaguire\OAuth2\Client\Provider\Bitbucket([
        'clientId'          => '{bitbucket-client-id}',
        'clientSecret'      => '{bitbucket-client-secret}',
        'redirectUri'       => 'https://example.com/callback-url'
    ]);
    
    $token = $_GET['code'];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-05
      • 2018-06-13
      • 1970-01-01
      • 1970-01-01
      • 2022-01-20
      • 1970-01-01
      • 1970-01-01
      • 2016-02-08
      相关资源
      最近更新 更多