TypechoJoeTheme

从南小站-致我逝去的青春

统计
登录
用户名
密码

王从南

我將一直快樂並且永遠如此

QQ翻译接口php

2020-09-18
/
2 评论
/
89 阅读
/
正在检测是否收录...
09/18

代码

<?php
$url = "https://wxapp.translator.qq.com/api/translate?sourceText=".urlencode($_GET["msg"])."&source=auto&target=auto&platform=MQQAPP&candidateLangs=zh%7Cen&guid=wxapp_openid_1576171882_ptxba365xp";
$rst= get_curl($url,0);
$nr1 = '/"targetText":"(.*?)"/';
preg_match_all($nr1,$rst,$nr1);
echo "内容:".$_GET['msg']."\n结果:".$nr1[1][0];

function get_curl($url,$post=0,$referer=1,$cookie=0,$header=0,$ua=1,$nobaody=0,$json=0){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$httpheader[] = "Accept:application/json";
$httpheader[] = "Accept-Encoding:gzip,deflate,sdch";
$httpheader[] = "Accept-Language:zh-CN,zh;q=0.8";
$httpheader[] = "Connection:close";
if($json){
$httpheader[] = "Content-Type:application/json; charset=utf-8";}
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
if($post){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);}
if($header){
curl_setopt($ch, CURLOPT_HEADER, TRUE);}
if($cookie){
curl_setopt($ch, CURLOPT_COOKIE, $cookie);}
if($referer){
if($referer==1){
curl_setopt($ch, CURLOPT_REFERER, 'http://m.qzone.com/infocenter?g_f=');
}else{
curl_setopt($ch, CURLOPT_REFERER, $referer);
}}
if($ua){
curl_setopt($ch, CURLOPT_USERAGENT,$ua);
}else{
curl_setopt($ch, CURLOPT_USERAGENT,'Dalvik/2.1.0 (Linux; U; Android 9; 16s Build/PKQ1.190202.001)');}
if($nobaody){
curl_setopt($ch, CURLOPT_NOBODY,1);}
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$ret = curl_exec($ch);
curl_close($ch);
return $ret;}

?>

参数

msg=要翻译的内容

接口事例

点击查看接口是否正常

QQPHP
朗读
赞(5)
赞赏
感谢您的支持,我会继续努力哒!

三合一收款

下面三种方式都支持哦

微信
QQ
支付宝
打开支付宝/微信/QQ扫一扫,即可进行扫码打赏哦
版权属于:

从南小站-致我逝去的青春

本文链接:

http://ouoo.fun/119.html(转载时请注明本文出处及文章链接)

评论 (2)
  1. Panting 作者
    Android · QQ Browser

    很棒

    2020-09-18 回复
    1. 王从南 作者
      Android · Google Chrome
      @Panting

      谢谢

      2020-09-19 回复