gpt4 book ai didi

url - Yii2-curl oAuth2 与 zoho

转载 作者:行者123 更新时间:2023-12-02 18:41:55 25 4
gpt4 key购买 nike

我正在开发 Yii2。我有一个 URL,在点击浏览器时会重定向到我的重定向 URI

网址

https://accounts.zoho.com/oauth/v2/auth?scope=ZohoBugTracker.projects.ALL,ZohoBugTracker.bugs.ALL&client_id=1000&response_type=code&access_type=offline&redirect_uri=http://11.111.111.111:7000/api/oauth/zoho_auth

当我点击上面的 URL 时,它会重定向到我的重定向 URI,同时提供代码

重定向 URI

点击上述 URL 后,重定向 URI 为 http://11.111.111.111:7000/api/oauth/zoho_auth?code=1000&location=us&accounts-server=https%3A%2F%2Faccounts.zoho.com

重定向 URI 响应

{"Message":"No HTTP resource was found that matches the request URI 'http://11.111.111.111:7000/api/oauth/zoho_auth?code=1000&location=us&accounts-server=https:%2F%2Faccounts.zoho.com'."}

如何从上述响应中获取代码

更新1

根据给出的建议。我尝试使用 linslin 发送 GET 请求。下面是我的代码

 public static function authToken()
{

$curl = new curl\Curl();
$response = $curl->setGetParams([
'scope' => 'ZohoBugTracker.projects.ALL,ZohoBugTracker.bugs.ALL',
'client_id' => '1000',
'response_type' => 'code',
'access_type' => 'offline',
'redirect_uri' => 'http://11.111.111.111:7000/api/oauth/zoho_auth',
])
->get('https://accounts.zoho.com/oauth/v2/auth');

echo $response;
exit();
}

然后在函数内调用此函数,通过该函数我实际上使用 zoho API 创建错误

通过 POSTMAN 测试我的 API

http://localhost:225/inventory-web/api/web/v1/installation/email?ref_no=28373340485858U&customer_id=37030315933&site_snap_name=28373340485858U_1530958224_site_9.jpg&flag=1

我的email函数是在API Controller 内编写的。因此,它首先会命中 issueSetup($param1,$param2)

public function actionEmail()
{
.
.
.
.

Installations::setupEmail($param1, $param2, $param3);
.
.
.
}

上述函数setupEmail($param1,$param2,$param3)位于我的 Controller 内部。

 public static function setupEmail($ref_no, $customer_id, $install_id)
{
.
.
.
.
.
list(params.....)= Installations::issueSetup($param1,$param2);
.
.
.
.
}

发布设置功能

public static function issueSetup($param1,$param2)
{
.
.
.
.
$token = Installations::authToken();

exit();
.
.
.
.
}

点击API后,我在 POSTMAN 中没有得到任何响应,只有空窗口

enter image description here

任何帮助将不胜感激。

最佳答案

当您启用 SSL 并检查响应代码/响应 header 以重定向到 Zuhu 上的 userAuth 表单时,它工作得很好:

$curl = new \linslin\yii2\curl\Curl();

/** @var Curl $response */
$curl->setGetParams([
'scope' => 'ZohoBugTracker.projects.ALL,ZohoBugTracker.bugs.ALL',
'client_id' => '1000',
'response_type' => 'code',
'access_type' => 'offline',
'redirect_uri' => 'http://11.111.111.111:7000/api/oauth/zoho_auth',
])->setOption(CURLOPT_SSL_VERIFYPEER, true)
->setOption(CURLOPT_SSL_VERIFYHOST, false)
->setOption(CURLOPT_CAINFO, 'C:/Ampps/apache/conf/ssl_crt/cacert.pem')
->get('https://accounts.zoho.com/oauth/v2/auth');

$responseHeaders = $curl->responseHeaders;

if ($curl->responseCode === 302 && isset($responseHeaders['Location'])) {
header("location: ".$responseHeaders['Location']);
die();
}

关于url - Yii2-curl oAuth2 与 zoho,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51360587/

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