收藏
回答

php7.4 图片检测security.msgSecCheck一直返回空?

$accessToken = $this->getAccessToken();
$url = "https://api.weixin.qq.com/wxa/img_sec_check?access_token={$accessToken}";

$curl = curl_init();

if (class_exists('\CURLFile')) {
    curl_setopt($curl, CURLOPT_SAFE_UPLOAD, true);
    $data = array('media' => new \CURLFile($imgUrl));//
} else {
    curl_setopt($curl, CURLOPT_SAFE_UPLOAD, false);
    $data = array('media' => '@' . $imgUrl);
}

curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_USERAGENT, "TEST");

$result = curl_exec($curl);

if ($result === false) {
    echo "error:" . curl_errno($curl);

    exit;

}
dd($result);


返回一直为空 ""


图片地址 https://******/storage/images/20210818/f8a0ef275e5de50852377b9f5aa40ef1f04d5747.png


回答关注问题邀请回答
收藏

1 个回答

  • 社区运营专员-wetingtu
    社区运营专员-wetingtu
    2021-08-23

    你好,调用问题请自行排查,可参考帖子:https://developers.weixin.qq.com/community/develop/doc/0006ee516a88605f3c3b1e4f056800?highLine=%25E5%2586%2585%25E5%25AE%25B9%25E5%25AE%2589%25E5%2585%25A8demo

    2021-08-23
    有用
    回复 1
    • Jiu_Teng
      Jiu_Teng
      2021-08-24
      返回空还是 


       $img = file_get_contents($imgUrl);
              $filePath = '/dev/shm/tmp1.png';
              file_put_contents($filePath, $img);
              $obj = new \CURLFile(realpath($filePath));
              $obj->setMimeType("image/png");
              $file['media'] = $obj;
              $token = $this->getAccessToken();
              $url = "https://api.weixin.qq.com/wxa/img_sec_check?access_token=$token";
              $curl = curl_init();
              curl_setopt($curl, CURLOPT_URL, $url);
              curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
              curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
              if (!empty($file)) {
                  curl_setopt($curl, CURLOPT_POST, TRUE);
                  curl_setopt($curl, CURLOPT_POSTFIELDS, $file);
              }
              curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
              $output = curl_exec($curl);
              if ($output === false) {
                  echo "error:" . curl_errno($curl);
                  die();
              }
              curl_close($curl);
              dd($output);
      2021-08-24
      回复
登录 后发表内容
问题标签