当前位置:网站首页>Baidu AI template for knowledge understanding
Baidu AI template for knowledge understanding
2022-06-24 09:40:00 【BigChen_ up】
<?php
namespace app\index\controller;
use think\Controller;
class Index extends Controller
{
// Search for
public function so()
{
if (request()->isPost() && request()->isAjax()) {
// Verification of origin
$access = $this->Access_token();
$token = $access['access_token'];
$url = "https://aip.baidubce.com/rpc/2.0/kg/v1/cognitive/entity_annotation?access_token=".$token;
$data = input('post.query'); // Receive information to search
$param = [
"data" =>$data,
];
$param = json_encode($param);
$data = $this->request_post($url,$param);
$res=json_decode($data,true);
$re = $res['entity_annotation'][0];
return json_encode($re,JSON_UNESCAPED_UNICODE);
}
}
public function request_post($url = '', $param = '') {
if (empty($url) || empty($param)) {
return false;
}
$postUrl = $url;
$curlPost = $param;
$curl = curl_init();// initialization curl
curl_setopt($curl, CURLOPT_URL,$postUrl);// Grab the specified page
curl_setopt($curl, CURLOPT_HEADER, 0);// Set up header
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);// Require the result to be a string and output to the screen
curl_setopt($curl, CURLOPT_POST, 1);//post submission
curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost);
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,false);
$data = curl_exec($curl);// function curl
curl_close($curl);
return $data;
}
public function Access_token()
{
$url = 'https://aip.baidubce.com/oauth/2.0/token';
$post_data['grant_type'] = 'client_credentials';
$post_data['client_id'] = '2oyd689nF4jj4EQoEf8skSIw';
$post_data['client_secret'] = 'm7WpmWpjClnEmsUeGkf08h29MynQyBeT';
$o = "";
foreach ($post_data as $k => $v) {
$o .= "$k=" . urlencode($v) . "&";
}
$post_data = substr($o, 0, -1);
$res = $this->request_post($url, $post_data);
// var_dump($res);
return json_decode($res, true);
}
}
Material Theme Ui
边栏推荐
- ORA-16038 ORA-19502 ORA-00312故障处理
- L01_ How is an SQL query executed?
- Easyexcel single sheet and multi sheet writing
- P6117-[joi 2019 final] greedy
- CDGA|到底怎么才能做好数据治理呢?
- ApplicationContextInitializer的三种使用方法
- Zero foundation self-study SQL course | syntax sequence and execution sequence of SQL statements
- Ggplot2 color setting summary
- 牛客网 实现简单计算器功能
- Oracle viewing data file header SCN information
猜你喜欢

医学图像开源数据集汇总(二)

PRCT-1400 : 未能执行 getcrshome解决方法

When programmers are asked if they can repair computers... | daily anecdotes

Netrca: an effective network fault cause localization

Talking about the knowledge of digital transformation

tp5 使用post接收数组数据时报variable type error: array错误的解决方法

Cdga | how can we do well in data governance?

Event registration Apache pulsar x kubesphere online meetup hot registration

零基础自学SQL课程 | HAVING子句

ggplot2颜色设置总结
随机推荐
Why is LNX of e equal to X
Oracle 12c升级至19c后ORA-28000错误
Go language project development practice directory
ggplot2颜色设置总结
如何解决独立站多渠道客户沟通难题?这款跨境电商插件一定要知道!
【Eureka注册中心】
【bug】@JsonFormat 使用时出现日期少一天的问题
Zero foundation self-study SQL course | sub query
Dynamic saving and recovery of FPU context under risc-v architecture
Threejs MMD model loading + contour loading + animation loading + Audio loading + camera animation loading +ammojs loading gltf model loading +gltf reflection adjustment
Reasons for the failure of digital transformation and the way to success
Learn Tai Chi Maker - esp8226 (12) esp8266 multitasking
每周推薦短視頻:談論“元宇宙”要有嚴肅認真的態度
Learning Tai Chi Maker - esp8226 (XIII) OTA
e的lnx为什么等于x
grpc本地测试联调工具BloomRPC
正则匹配邮箱
医学图像开源数据集汇总(二)
[GDB debugging tool] | how to debug under multithreading, multiprocessing and running programs
正则匹配手机号