PHP使用SOAP调用远程API

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u013101178/article/details/84998997
/*图片转换为 base64格式编码*/
function base64EncodeImage($image_file)
{
    $base64_image = '';
    $image_info = getimagesize($image_file);
    $image_data = fread(fopen($image_file, 'r'), filesize($image_file));
    //$base64_image = 'data:' . $image_info['mime'] . ';base64,' . chunk_split(base64_encode($image_data));
    $base64_image = chunk_split(base64_encode($image_data));
    return $base64_image;
}

$strPhotoFront_base64 = base64EncodeImage("static/img/a.png");
$strPhotoRear_base64 = base64EncodeImage("static/img/b.png");

$paras["strPhotoFront"] = $strPhotoFront_base64;
$paras["strPhotoRear"] = $strPhotoRear_base64;
$paras["strSecretKey"] = "";

$wsdl = "";
$client = new SoapClient($wsdl);
$soapParas = array($paras);
$outString = $client->__soapCall("UploadPhotoId", $soapParas);
$obj = simplexml_load_string($outString->UploadPhotoIdResult->any);

echo($obj->ExtraInfo);
echo "<br/>";
echo($obj->ExtraCode);
echo "<br/>";
echo($obj->Code);
echo "<br/>";
echo($obj->Message);

猜你喜欢

转载自blog.csdn.net/u013101178/article/details/84998997
今日推荐