激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - PHP教程 - PHP使用SOAP調用API操作示例

PHP使用SOAP調用API操作示例

2019-07-09 16:52ChouCat PHP教程

這篇文章主要介紹了PHP使用SOAP調用API操作,結合實例形式分析了php基于SOAP調用API的常見操作技巧及相關問題解決方法,需要的朋友可以參考下

本文實例講述了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 "<br/>";
echo($obj->ExtraCode);
echo "<br/>";
echo($obj->Code);
echo "<br/>";
echo($obj->Message);

注:出現提示:Fatal error: Class 'SoapClient' not found的情況,可參考《PHP Class SoapClient not found解決方法

附:SOAP-ERROR: Parsing WSDL:Couldn't load from “xxxxxxx” 解決方案

用php的soapclient連接第三方的webservice,是https的,連接報錯SOAP-ERROR: Parsing WSDL:Couldn't load from “xxxxxxx”

首先排查 php的soap擴展是否安裝

openssl擴展

服務器本身安裝openssl

排除第三方對本服務器的IP限制

最后懷疑是https需要ssl驗證,而本機沒有pem文件

可以通過如下設置,忽略ssl驗證

verify_peer:指定是否驗證ssl,默認為true

將verify_peer設為false

另外,允許引用外部xml實體

libxml_disable_entity_loader(false);語句

libxml_disable_entity_loader(false);
$opts = array(
  'ssl'  => array(
      'verify_peer'     => false
    ),
  'https' => array(
      'curl_verify_ssl_peer' => false,
      'curl_verify_ssl_host' => false
   )
);
$streamContext = stream_context_create($opts);
$client = new SoapClient("https://urlToSoapWs",
 array(
   'stream_context'  => $streamContext
 ));

禁止引用外部xml實體

libxml_disable_entity_loader(true);

nginx 報錯 upstream timed out (110: Connection timed out)解決方案

nginx每隔幾個小時就會報下面的錯誤:

2013/05/18 21:21:36 [error] 11618#0: *324911 upstream timed out (110: Connection timed out) while reading response header from upstream,
client: 42.62.37.56, server: localhost, request: “GET /code-snippet/2747/HTML5-Canvas-usage HTTP/1.0”,
upstream: “fastcgi://127.0.0.1:9002”, host: “outofmemory.cn”, referrer: “http://outofmemory.cn/code-snippet/tagged/canvas“

報這個錯誤之后,整個服務器就不響應了,但是nginx后面的webpy程序沒有任何錯誤,后端的數據庫也很正常,從網上查了很多資料,都是說要修改proxy_read_timeout,proxy_send_timeoutproxy_buffer幾個相關設置的值。

如下配置,要放在server配置節之內

large_client_header_buffers 4 16k;
client_max_body_size 30m;
client_body_buffer_size 128k;
proxy_connect_timeout 300;
proxy_read_timeout 300;
proxy_send_timeout 300;
proxy_buffer_size 64k;
proxy_buffers   4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
fastcgi_connect_timeout 300;
fastcgi_read_timeout 300;
fastcgi_send_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers   4 32k;
fastcgi_busy_buffers_size 64k;
fastcgi_temp_file_write_size 64k;

你可以看到上面是proxy_fastcgi_兩種配置,就是說如果你的nginx后面是proxy,就設置proxy相關的配置,如果是fastcgi就設置fastcgi相關的配置。

希望本文所述對大家PHP程序設計有所幫助。

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 毛片在线不卡 | 日韩欧美激情视频 | 色屁屁xxxxⅹ在线视频 | 91在线视频精品 | 美女久久| freexxxhd喷水| 99久久久久国产精品免费 | 一级毛片在线观看免费 | 久久精品观看 | 伊人在线 | 色天使中文字幕 | 日韩精品二区 | 国产99久久久久久免费看农村 | 国产成人精品区一区二区不卡 | 亚洲综合网站 | 性生活视频一级 | 色综合中文字幕 | 久久亚洲视频网 | aa国产视频一区二区 | 精品国产乱码久久久久久丨区2区 | 精品国产一区二区三区四区在线 | 欧美成人一区二区三区电影 | 亚洲午夜免费电影 | 黄色日韩网站 | 午夜a狂野欧美一区二区 | 精品小视频 | 99re色| 久久99精品久久久久久国产越南 | 艹男人的日日夜夜 | 国产中文一区 | 香蕉视频网站在线观看 | 国产色片 | 男人天堂新地址 | av电影网站在线观看 | 一区二区国产在线 | 欧美一级特黄a | 成人短视频在线观看 | 一级毛片在线免费播放 | avav在线播放 | 国产一级一区二区三区 | 免费在线一级毛片 |