使用EHttpClient Yii的出站efax开发人员api请求不起作用

问题描述 投票:0回答:2

我正在使用EHttpClient扩展名yii。我的代码:

$file = file_get_contents($path, true);

Yii::import('ext.EHttpClient.*');

$client = new EHttpClient('https://secure.efaxdeveloper.com/EFax_WebFax.serv', array(
    'maxredirects' => 3,
    'timeout'      => 30,
    'Content-Type' => 'application/x-www-form-urlencoded',
    'adapter'      => 'EHttpClientAdapterCurl'));

$client->setParameterPost(array('id'=>urlencode("2313125942"), 'xml'=>urlencode($file)));


SiteHelper::printShow($client);

$response = $client->request("POST");

var_dump($response->isSuccessful());
SiteHelper::printShow($response);

我的xml数据:

<?xml version="1.0"?>
<OutboundRequest>
    <AccessControl>
        <UserName>b23s2323</UserName>
        <Password>b23s2323</Password>
    </AccessControl>
    <Transmission>

        <TransmissionControl>
            <Resolution>STANDARD</Resolution>
        </TransmissionControl>

        <DispositionControl>
            <DispositionLevel>BOTH</DispositionLevel>
            <DispositionEmails>
                <DispositionEmail>
                    <DispositionAddress>[email protected]</DispositionAddress>
                </DispositionEmail>
            </DispositionEmails>
        </DispositionControl>

        <Recipients>
            <Recipient>
                <RecipientFax>8189790412</RecipientFax>
            </Recipient>
        </Recipients>

        <Files>
            <File>
                <FileContents>Base64 pdf here</FileContents>
                <FileType>pdf</FileType>
            </File>
        </Files>

    </Transmission>
</OutboundRequest>

我的要求的信息:

EHttpClient Object
(
    [config:protected] => Array
        (
            [maxredirects] => 3
            [strictredirects] => 
            [useragent] => EHttpClient
            [timeout] => 30
            [adapter] => EHttpClientAdapterCurl
            [httpversion] => 1.1
            [keepalive] => 
            [storeresponse] => 1
            [strict] => 1
            [output_stream] => 
            [encodecookies] => 1
            [rfc3986_strict] => 
            [content-type] => application/x-www-form-urlencoded
        )

    [adapter:protected] => 
    [uri:protected] => EUriHttp Object
        (
            [_username:protected] => 
            [_password:protected] => 
            [_host:protected] => secure.efaxdeveloper.com
            [_port:protected] => 443
            [_path:protected] => /EFax_WebFax.serv
            [_query:protected] => 
            [_fragment:protected] => 
            [_regex:protected] => Array
                (
                    [alphanum] => [^\W_]
                    [escaped] => (?:%[\da-fA-F]{2})
                    [mark] => [-_.!~*'()\[\]]
                    [reserved] => [;\/?:@&=+$,]
                    [unreserved] => (?:[^\W_]|[-_.!~*'()\[\]])
                    [segment] => (?:(?:(?:[^\W_]|[-_.!~*'()\[\]])|(?:%[\da-fA-F]{2})|[:@&=+$,;])*)
                    [path] => (?:\/(?:(?:(?:[^\W_]|[-_.!~*'()\[\]])|(?:%[\da-fA-F]{2})|[:@&=+$,;])*)?)+
                    [uric] => (?:[;\/?:@&=+$,]|(?:[^\W_]|[-_.!~*'()\[\]])|(?:%[\da-fA-F]{2}))
                )

            [_scheme:protected] => https
        )

    [headers:protected] => Array
        (
        )

    [method:protected] => GET
    [paramsGet:protected] => Array
        (
        )

    [paramsPost:protected] => Array
        (
            [id] => 2313125942
            [xml] => The%encoded%url%xml%data
        )

    [cookiejar:protected] => 
    [last_request:protected] => 
    [last_response:protected] => 
    [redirectCounter:protected] => 0
    [_unmaskStatus:protected] => 
    [_queryBracketsEscaped:protected] => 1
)

我已经从https://secure.efaxdeveloper.com/downloads.jsp Outbound中读取了文档,已经在xml数据上设置了所有必填字段并请求发布。但我总是从efax开发人员API中得到这个错误:

Post Unsuccessful!
Your request has failed due to invalid data.
Please refer to our documentation prior to resubmitting.

Error Level: User
Error Message: XML data argument was not passed.

Please contact us at 888-278-8666 if you continue to encounter errors.

错误消息:未传递XML数据参数我的xml数据有什么问题?

(*请注意我的请求xml post参数设置了我的xml的编码文件内容)。

php xml api yii fax
2个回答
1
投票

我用PHP efax代替。

PHP eFax是一个包装eFax®DeveloperAPI的PHP类。使用PHP eFax自动完成从PHP驱动的Web服务器以电子方式发送和接收传真的任务。


0
投票

不要使用urlencode。只需将内容类型设置为application / x-www-form-urlencoded即可。

© www.soinside.com 2019 - 2024. All rights reserved.