PHP code example of klinson / ms-xiaoice

1. Go to this page and download the library: Download klinson/ms-xiaoice library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

klinson / ms-xiaoice example snippets


// $img 可以是路径、url、图片base64内容
$res = XiaoIce::getInstance()->appraiseScore($img_path_or_url);
$res = XiaoIce::getInstance()->appraiseScore($img_base64, true);
var_dump($res);

// $img 可以是路径、url、图片base64内容
$res = XiaoIce::getInstance()->competeAppearance($img_path_or_url);
$res = XiaoIce::getInstance()->competeAppearance($img_base64, true);
var_dump($res);

// $img 可以是路径、url、图片base64内容
$res = XiaoIce::getInstance()->speculateCP($img_path_or_url);
$res = XiaoIce::getInstance()->speculateCP($img_base64, true);
var_dump($res);

// $img 可以是路径、url、图片base64内容
$res = XiaoIce::getInstance()->whoTreat($img_path_or_url);
$res = XiaoIce::getInstance()->whoTreat($img_base64, true);
var_dump($res);

// $img 可以是路径、url、图片base64内容
$res = XiaoIce::getInstance()->speculateAge($img_path_or_url);
$res = XiaoIce::getInstance()->speculateAge($img_base64, true);
var_dump($res);
shell
array(3) {
  ["result"]=>
  float(5.2)
  ["text"]=>
  string(263) "深度神经网络输出的结果显示,全球各类人群中美国90后男性最喜欢这种容貌,给出的分数是5.2。不过这张脸在法国小姐姐和法国小哥哥眼中,颜值平平。讲道理,照片上的人蛮亲切的,特别是眼睛。"
  ["image_url"]=>
  string(170) "https://mediaplatform.msxiaobing.com/image/fetchimage?key=UQAfAC8ABAAAAFcAFgAGABYASgBFADMAQQA4ADQARQA2ADcAOQBEAEUAMAAyADMANQBDADQAMQAwADAANQA4AEYARgBCAEUANwA5ADMANAA4ADMA"
}
shell
array(3) {
  ["result"]=>
  int(0)
  ["text"]=>
  string(77) "鲜花往往喜欢插在XX上(XX不好闻),快让美女大喊:我喜欢XX"
  ["image_url"]=>
  string(172) "http://mediaplatform.trafficmanager.cn/image/fetchimage?key=UQAfAC8ABAAAAFcAFgAGABYASgBCAEEANQBDAEQANQA3ADYARAA3ADQARABDADQAQQBFADcAOABCADgARgAzAEQANQAzAEIAQgBBADMANQBFAEQA"
}

shell
array(3) {
  ["result"]=>
  int(0)
  ["text"]=>
  NULL
  ["image_url"]=>
  string(172) "http://mediaplatform.trafficmanager.cn/image/fetchimage?key=UQAfAC8ABAAAAFcAFgAGABYASgAyADcAQwAzADQARAA5AEEANwAyADEANwA4ADUAOQBBADQANwBDAEYARABEAEUANgBCADQAMAAxAEUAQgA5ADEA"
}