如何使用 php-upwork-oauth2 取得 upwork 用戶端
P粉627027031
P粉627027031 2024-03-30 00:41:19
0
1
378

我正在使用 php-upwork-oauth2 套件和 symfony 來獲取我的 upwork 設定檔資訊。

基於此儲存庫:https://github.com/upwork/php-upwork-oauth2/blob/master/example/example.php 我新增了我的 clientId 和 clientSecret:

$config = new \Upwork\API\Config([
        'clientId'          => '...', // SETUP YOUR CONSUMER KEY
        'clientSecret'      => '...', // SETUP KEY SECRET
        'redirectUri'       => 'https://localhost:8000/upwork',
        'accessToken'       => $session->get('access_token'),
        'accessSecret'      => $session->get('access_secret'),
        //'expiresIn'         => 'xxxxxxxxxx', // WARNING: keep this up-to-date!
        'debug'             => true, // enables debug mode
        //'authType'          => 'MyOAuthPHPLib' // your own authentication type, see AuthTypes directory
    ]);

    $client = new \Upwork\API\Client($config);

    $auth = new \Upwork\API\Routers\Auth($client);

    $info = $auth->getUserInfo();

    dd($info);

如何取得 accessToken 和 accessSecret ?

我目前收到此錯誤:

呼叫字串上的成員函數 getBody()

P粉627027031
P粉627027031

全部回覆(1)
P粉696605833

程式碼中的 $session->get('access_token'), 是什麼?是否設定了某些內容? 我建議:

  1. 註解掉 accessTokenaccessSecret
  2. 遵循身分驗證和授權流程
  3. grep 收到訪問令牌/秘密
  4. 將令牌對加入到組態中
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!