欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 PHP调用小黄鸡 api post发送,代码: !-- index.php --页面 meta http-equiv="Content-Type" content="text/html; charset=utf-8" / ?php function do_post_request($url, $data, $optional_headers
欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入
PHP调用小黄鸡 api post发送,代码:
页面
function do_post_request($url, $data, $optional_headers = null)
{
$params = array('http' => array(
'method' => 'POST',
'content' => $data
));
if ($optional_headers !== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if (!$fp) {
throw new Exception("Problem with $url, $php_errormsg");
}
$response = @stream_get_contents($fp);
if ($response === false) {
throw new Exception("Problem reading data from $url, $php_errormsg");
}
return $response;
}
function simi($value="Love"){
$url = 'http://www.xiaohuangji.com/ajax.php';
$postdata = array("para"=>$value);
$postdata = http_build_query($postdata);
return do_post_request($url,$postdata);
}echo simi("Love");
?>
调用这个这段的代码就是
// 装载小黄鸡函数
// @author ipqhjjybj
// @data 2013.11.30
// 调用方法:
// $result = simi($str);
// $result String类型 是返回的内容文本
// $str String类型 是要回答的内容
也可以用CURL来做
function curl_post($url, array $post = NULL, array $options = array())
{
$defaults = array(
CURLOPT_POST => 1,
CURLOPT_HEADER => 0,
CURLOPT_URL => $url,
CURLOPT_FRESH_CONNECT => 1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_FORBID_REUSE => 1,
CURLOPT_TIMEOUT => 4,
CURLOPT_POSTFIELDS => http_build_query($post)
);
$ch = curl_init();
curl_setopt_array($ch, ($options + $defaults));
if( ! $result = curl_exec($ch))
{
trigger_error(curl_error($ch));
}
curl_close($ch);
return $result;
}
function simi($value = "Love")
{
$post_data = array ("para"=>$value) ;
$url ='http://www.xiaohuangji.com/ajax.php';
return curl_post($url,$post_data);
}
[1] [2]

Outils d'IA chauds

Undresser.AI Undress
Application basée sur l'IA pour créer des photos de nu réalistes

AI Clothes Remover
Outil d'IA en ligne pour supprimer les vêtements des photos.

Undress AI Tool
Images de déshabillage gratuites

Clothoff.io
Dissolvant de vêtements AI

Video Face Swap
Échangez les visages dans n'importe quelle vidéo sans effort grâce à notre outil d'échange de visage AI entièrement gratuit !

Article chaud

Outils chauds

Adaptateur de serveur SAP NetWeaver pour Eclipse
Intégrez Eclipse au serveur d'applications SAP NetWeaver.

VSCode Windows 64 bits Télécharger
Un éditeur IDE gratuit et puissant lancé par Microsoft

SublimeText3 Linux nouvelle version
Dernière version de SublimeText3 Linux

mPDF
mPDF est une bibliothèque PHP qui peut générer des fichiers PDF à partir de HTML encodé en UTF-8. L'auteur original, Ian Back, a écrit mPDF pour générer des fichiers PDF « à la volée » depuis son site Web et gérer différentes langues. Il est plus lent et produit des fichiers plus volumineux lors de l'utilisation de polices Unicode que les scripts originaux comme HTML2FPDF, mais prend en charge les styles CSS, etc. et présente de nombreuses améliorations. Prend en charge presque toutes les langues, y compris RTL (arabe et hébreu) et CJK (chinois, japonais et coréen). Prend en charge les éléments imbriqués au niveau du bloc (tels que P, DIV),

Dreamweaver CS6
Outils de développement Web visuel
