url - Yii2-curl oAuth2 与 zoho
问题描述
我正在努力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":"未找到与请求 URI ' http://11.111.111.111:7000/api/oauth/zoho_auth?code=1000&location=us&accounts-server=https:%2F%2Faccounts.zoho 匹配的 HTTP 资源。 com '。”}
如何code
从上述响应中获得?
更新 1
根据给出的建议。我尝试GET
使用linslin发送请求。下面是我的代码
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 创建错误
测试我的API
通过POSTMAN
我的email
函数是在 API 控制器中编写的。所以,它会首先击中issueSetup($param1,$param2)
public function actionEmail()
{
.
.
.
.
Installations::setupEmail($param1, $param2, $param3);
.
.
.
}
上面的函数setupEmail($param1,$param2,$param3)
在我的控制器里面。
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 中没有得到任何响应,只是空窗口
任何帮助将不胜感激。
解决方案
当您启用 SSL 并检查响应代码/响应标头以重定向到 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();
}
推荐阅读
- javascript - 剪辑路径动画第二次不起作用
- html - 将表单数据数组对象转换为 JSON
- python-3.x - 如何计算时间戳的一部分
- google-apps-script - 使用 GCP Classic VPN 路由的 Google App 脚本(不)?
- android - Android Studio 中缺少 ObservableList?
- python - 如何在 altair 图中获取与 y 轴一起添加的列值
- oracle - How to concatenate strings in oracle pl/sql loop?
- java - 将行为卸载到另一个类
- python - 在 Jupyter 笔记本中打开超链接
- sql - 返回特定列具有重复值的行