【问题标题】:Connect Zoom with Codeigniter (curl)将 Zoom 与 Codeigniter (curl) 连接起来
【发布时间】:2021-04-25 20:36:00
【问题描述】:

我想将 Zoom 与 Codeigniter 连接,但我遇到了问题。

我创建了一个 ZOOM 应用程序(等待 Zoom 批准),我有一个客户端 ID 和 redirect_uri。 我定义了client_id、client_secret和redirect_uri。

$hash = base64_encode($client_id . ':' . $client_secret);
$headers = array(       
    'Authorization: Basic ' . $hash 
); 
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://zoom.us/oauth/authorize?response_type=code&client_id='.$client_id.'&redirect_uri='.$redirect_uri);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
//curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('data'=>($data))));

$result = curl_exec($ch);
$all=json_decode($result);               
print_r($all);

当我执行此代码时,我得到了 stdClass 对象( [status] => [errorCode] => 202 [errorMessage] => 出了点问题。请刷新此页面。[result] =>)。

你能帮帮我吗?谢谢!!

【问题讨论】:

    标签: php http curl


    【解决方案1】:

    您似乎混淆了 OAuth 流程的两个步骤。

    OAuth 流程应如下所示:

    1. 您使用client_idgrant_typeredirect_uriscope 将用户重定向到授权 URL(您在请求中列出的 URL)。
    2. OAuth 提供程序 (Zoom) 使用查询字符串参数 code 将您的用户重定向回您的 redirect_uri
    3. 您使用Authorization 标头中的client_idclient_secret(在您的$headers 变量中)和coderedirect_uri 向令牌端点发出POST 请求,和 grant_type 在正文中(通常是 URL 格式编码)。此请求的返回值包括访问令牌(和刷新令牌)。

    您似乎将 #1 中的请求与 #3 中的请求混淆了。

    您可以考虑使用托管 OAuth 服务来为您执行此操作,例如我工作的 Xkit。在那里,您只需要提供您的 Zoom OAuth 凭据,它们就会处理所有重定向、请求等。您所做的就是对 Xkit 进行 API 调用,它们将返回一个访问令牌。这是他们的Zoom Setup guide 供参考。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-12
      • 1970-01-01
      • 2016-10-08
      • 1970-01-01
      • 2017-07-13
      • 2017-09-24
      • 2014-08-16
      相关资源
      最近更新 更多