图灵机器人

本文深入探讨了图灵机器人技术,揭示了其在智能对话和自然语言处理领域的应用。通过图灵机器人,开发者可以创建逼真的聊天体验,为用户带来智能化的服务交互。同时,文章还讨论了其在人工智能助手、在线客服以及个性化推荐等方面的关键作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<?php 

namespace Gdali\Tuling123SDK; 
 
class Tuling123
{
    
    private $apiKey;
    private $secret;
    private $text;
    private $userId = 1;
    private $selfInfo = '';
    
    public function  __construct($apiKey, $secret, $userId, $selfInfo){
        
        $this->apikey = $apiKey;
        $this->secret = $secret;
        $this->userId = md5($userId);
	    $this->selfInfo = $selfInfo; 	    
        $this->timestamp = time();		
        
    }
    
    public function tuling($text, $raw = false){
		
	    $this->text = $text;    
        $iv = '';
        $iv = str_repeat(chr(0),16);
		
        $aesKey = md5($this->secret.$this->timestamp.$this->apikey);
		
        $param = [
            'perception' => [
                'inputText' => [
                    'text' => $this->text,
                ],
                'selfInfo' => $this->selfInfo
            ],
            'userInfo' => [
                'apiKey' => $this->apikey,
                'userId' => $this->userId,
            ]
        ];

        $cipher = base64_encode(openssl_encrypt(json_encode($param), 'aes-128-cbc', hash('MD5', $aesKey, true), OPENSSL_RAW_DATA, $iv));
			
        $postData = [
            'key' => $this->apikey,
            'timestamp' => $this->timestamp,
            'data' => $cipher
        ];
		
        $result = json_decode('['.$this->post('http://openapi.tuling123.com/openapi/api/v2',json_encode($postData)).']',true);
        
        return $raw ? $result : $result[0]['results'][0]['values']['text'];
        
    }
    
    private function post($url,$data){
        
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_HEADER, 0);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_TIMEOUT, 500);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($curl, CURLOPT_URL, $url);
        $result = curl_exec($curl);
        curl_close($curl);
		
        return $result;  
        
    }
    
}
?>

 

<?php 
 
namespace Gdali\Tuling123SDK;

require __DIR__.'/vendor/autoload.php';

$selfInfo = [
    'location' => [
        'city' => '滑县'
    ]
];

$data = new Tuling123('appID','appKey','userID',$selfInfo);

$result = $data->tuling('您好');

echo $result;

?>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值