PHP使用SOAP调用API

/*图片转换为 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 "
"; echo($obj->ExtraCode); echo "
"; echo($obj->Code); echo "
"; echo($obj->Message);

你可能感兴趣的:(php)