1

我需要一些帮助来连接到 deviantArt 的 whois API。

我正在构建一个需要连接到 deviantArt 的 API 的 Laravel 应用程序。

我能够使用SocialiteThe League 的 OAuth2-ClientGuzzle和 cUrl 成功连接到 API,但仅限于 whoami 请求。
获取 /user/whoami

我可以成功whois连接,但只能使用 cUrl。
发布 /user/whois

curl https://www.deviantart.com/api/v1/oauth2/user/whois \
-d "usernames[0]=justgalym" \
-d access_token=Alph4num3r1ct0k3nv4lu3

我想尽可能多地使用 OAuth2-Client 插件,但在这一点上,我只是在寻找可行的东西。

我最好的猜测是我没有POST正确发送变量。

尝试 1 - 使用 Guzzle 请求

$options = [
  'form_params' => [
    'usernames[0]' => 'justgalym',
    'expand' => 'user.profile',
  ],
  "Authorization" => "Bearer ".$this->token->getToken()
];

$request = new Request('POST', $url, $options);

尝试 2 - 使用 Guzzle 请求

$options = [
  'form_params' => [
    'usernames[]' => 'justgalym',
    'expand' => 'user.profile',
  ],
  "Authorization" => "Bearer ".$this->token->getToken()
];

$request = new Request('POST', $url, $options);

尝试 3 - 使用 Guzzle 请求

$options = [
  'form_params' => [
    'usernames' => 'justgalym',
    'expand' => 'user.profile',
  ],
  "Authorization" => "Bearer ".$this->token->getToken()
];

$request = new Request('POST', $url, $options);

尝试 4 - 使用 Guzzle 请求

$options = [
  'form_params' => [
    'usernames' => 
       [0 => 'justgalym'],
    'expand' => 'user.profile',
  ],
  "Authorization" => "Bearer ".$this->token->getToken()
];

$request = new Request('POST', $url, $options);

尝试 5 - 使用 Oauth-client getAuthenticatedRequest

$request = $this->provider->
           getAuthenticatedRequest(
               AbstractProvider::METHOD_POST, 
               $url, $this->token,  ['body' => 'usernames[0]=justgalym'
]);

试图 ...

和许多其他人

所有尝试的结果都给我同样的错误。

array(
  'error' => 'invalid_request', 
  'error_description' => 'Request field validation failed.', 
  'error_details' => 
    array(
      'usernames' => 'usernames is required'
    ), 
  'status' => 'error'
)
4

0 回答 0