在 PHP 中使用 PFC 发货 API

Using PFC shipping API in PHP

我正在尝试使用 pfc 运输 api http://www.pfcexpress.com/webservice/EnAPIDoc.html

我正在尝试 运行 简单的 getCountry 方法,该页面上的第一个方法。 您还可以在此页面上找到它 http://bit.ly/1Lq4t6G 只需使用密钥 pfc123456789 并点击搜索

我的问题是第一个 link 教程中的示例是针对 .Net 的,我只知道 php 并将其集成到 php

根据他们的教程

对于.NET 先step:In自己的project:asp.net,添加网页报价,提供PFC提供的API服务网站地址。假定为:"http://pfcexpress.com/webservice/APIWebService.asmx"

Second step:Initialization,then use the method,can obtain the data
pfc.pfcwebservice p=new pfc.pfcwebservice();
string result = p.getCountry(secretkey);

我正在为 php 使用 curl $curl = curl_init(); curl_setopt_array($curl, 数组( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => 'http://www.pfcexpress.com/webservice/APIWebService.asmx/getCountry', CURLOPT_POST => 1, CURLOPT_POST字段 => 数组( 密钥 => '2add5e13-3b85-45a9-9fcc-4b739de2b1b784342' ) ));

    $resp = curl_exec($curl);
    $r = mb_convert_encoding($resp,'ISO-8859-1','utf-8');
    print_r($r);

    curl_close($curl);  

但是没有成功。 但是得到以下错误

[InvalidOperationException: 因 URL 意外地以“/getCountry”结束,请求格式无法识别。]
   System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) +489333
   System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +212
   System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) +47
   System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +346
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

我不明白 .Net 错误

非常感谢任何帮助。 谢谢。

我通过从 CURL 转移到 SOAP 解决了这个问题,正如上面 Ryan 在评论中指出的那样。 我们需要使用 SOAP 连接到 .net 'asmx' 服务