佣金交界日报出版商佣金服务

发布于 2024-10-06 09:50:16 字数 771 浏览 2 评论 0 原文

我正在创建一个带有 Commission Junction 链接的网站。现在我需要处理佣金报告以分配佣金。我计划使用每日出版商佣金服务,因为它提供了在请求中包含日期的规定。现在我无法通过 CJ 链接进行购买,因此我使用 CJ 网站本身。我对这些 wbservices 很陌生,因此对此有一些疑问。

  1. 实际响应将与给出的响应完全相同。我的意思是它会包含
    事情或者它只是从 ns1 开始。???

  2. 我已将响应分配给变量 $result 并给出

    $result_xml=simplexml_load_string($result);

但它显示 ns1 未在命名空间中定义的错误。然后我将 的东西放到了顶部。现在错误已经消失了。但 result_xml 变量为空。

如果有人以前做过,请帮助我。或者请给我推荐一些好的教程,以便我可以学习并做到这一点。如果有人可以提供完整的示例响应,那将非常有帮助,这样我就可以用它检查代码。

提前致谢。

I am creating a website with the Commission Junction links,. Now I need to process the commission reports for dividing the commissions. I am planning to use Daily Publisher Commission Service as it provides a provision for including the date in the request. Now I am not able to do a purchase through the CJ link and so I am using a sample query that has given in CJ site itself. I am new to these wbservices and so have some doubts here.

  1. The actual respone will be exactly same as the one given. I mean will it includes the <soapenv:Envelope
    things or it is begin with just the ns1.???

  2. I have assigned the response to a variable $result and give

    $result_xml=simplexml_load_string($result);

but it is showing the error that ns1 is not defined in namespace. Then I have given the <soapenv:Envelope things to the top. Now the error has gone. But the result_xml variable is blank .

Please help me if someone has done it before. or please suggest me some good tutorials so that I can learn and do it. It will be much helpful if someone can give the complete sample response and so I can check the code with it.

Thanks in Advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

说好的呢 2024-10-13 09:50:16

对 SOAP 请求的 XML 响应类似于:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soap:Body>
        <findPublisherCommissionsResponse xmlns="http://api.cj.com">
            <out xmlns="http://api.cj.com">
                <publisherCommissions xmlns="http://transaction.service.cj.com">
                    <ns1:PublisherCommissionV2 xmlns:ns1="http://transaction.domain.cj.com">
                        <actionStatus xmlns="http://transaction.domain.cj.com">
                            closed
                        </actionStatus>
                        <actionType xmlns="http://transaction.domain.cj.com">
                            sale
                        </actionType>
                        <adId xmlns="http://transaction.domain.cj.com">
                            13123123
                        </adId>
                        <advertiserId xmlns="http://transaction.domain.cj.com">
                            12312312
                        </advertiserId>
                        <advertiserName xmlns="http://transaction.domain.cj.com">
                            Merchant UK ltd
                        </advertiserName>
                        <commissionAmount xmlns="http://transaction.domain.cj.com">
                            25
                        </commissionAmount>
                        <country xmlns="http://transaction.domain.cj.com">
                        </country>
                        <eventDate xmlns="http://transaction.domain.cj.com">
                            2009-08-28T20:30:44-07:00
                        </eventDate>
                        <lockingDate xmlns="http://transaction.domain.cj.com">
                            2009-09-10T00:00:00-07:00
                        </lockingDate>
                        <orderId xmlns="http://transaction.domain.cj.com">
                            1231232
                        </orderId>
                        <original xmlns="http://transaction.domain.cj.com">
                            true
                        </original>
                        <originalActionId xmlns="http://transaction.domain.cj.com">
                            12312321312
                        </originalActionId>
                        <postingDate xmlns="http://transaction.domain.cj.com">
                            2009-08-28T23:30:03-07:00
                        </postingDate>
                        <sId xmlns="http://transaction.domain.cj.com">
                            googlelink
                        </sId>
                        <saleAmount xmlns="http://transaction.domain.cj.com">
                            25
                        </saleAmount>
                        <transactionId xmlns="http://transaction.domain.cj.com">
                            123123123
                        </transactionId>
                        <websiteId xmlns="http://transaction.domain.cj.com">
                            1231231
                        </websiteId>
                    </ns1:PublisherCommissionV2>
                </publisherCommissions>
                <sortBy xmlns="http://transaction.service.cj.com">
                </sortBy>
                <totalResults xmlns="http://transaction.service.cj.com">
                    1
                </totalResults>
            </out>
        </findPublisherCommissionsResponse>
    </soap:Body>
</soap:Envelope>

您可能在将 xml 响应解析为 SimpleXml 对象时遇到问题,因为 SimpleXML 不喜欢标签和属性名称中的冒号 (:) SOAP 和SimpleXML。另请检查此处 SimpleXML &命名空间

您的 SOAP 请求应该已经是一个对象,因此我不确定您为什么尝试使用 SimpleXML 解析它。如果您需要 XML 形式的响应,那么您始终可以使用 序列化器

以我自己的脚本为例,我使用这样的内容:

//code here
$cj_devkey = "这里是 CJ 密钥";

        $ini    = ini_set( "soap.wsdl_cache_enabled", "0" );
        $client = new SoapClient( "https://pubcommission.api.cj.com/wsdl/version2/publisherCommissionServiceV2.wsdl", array(
             'trace' => true,
            'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP,
            'proxy_host' => "proxy" 
        ) );

        $object = $client->findPublisherCommissions( array(
             "developerKey" => $cj_devkey,
            "date" => '08/28/2009',
            "dateType" => 'event',
            "advertiserIds" => '',
            "websiteIds" => '123456',
            "actionStatus" => '',
            "actionTypes" => 'sale',
            "adIds" => '',
            "countries" => 'all',
            "correctionStatus" => 'all',
            "sortBy" => '',
            "sortOrder" => '' 
        ) );

使用 print_r($object) 的示例响应将返回:

stdClass Object
(
    [out] => stdClass Object
        (
            [publisherCommissions] => stdClass Object
                (
                    [PublisherCommissionV2] => stdClass Object
                        (
                            [actionStatus] => closed
                            [actionType] => sale
                            [adId] => 123123213
                            [advertiserId] => 2313531
                            [advertiserName] => MERCHANT HERE
                            [commissionAmount] => 25
                            [country] => 
                            [eventDate] => 2009-08-28T20:30:44-07:00
                            [lockingDate] => 2009-09-10T00:00:00-07:00
                            [orderId] => 123123
                            [original] => 1
                            [originalActionId] => 123123
                            [postingDate] => 2009-08-28T23:30:03-07:00
                            [sId] => sports
                            [saleAmount] => 25
                            [transactionId] => 12312312
                            [websiteId] => 123123
                        )

                )

            [sortBy] => 
            [totalResults] => 1
        )

)

如果您想遍历对象元素,您可以使用以下内容:

$num_results = $object->out->totalResults;

或使用以下内容循环遍历每个佣金付款:

foreach ( $object->out->publisherCommissions as $commission ) {
                $user_id        = $commission->{'sId'};
                $transaction_id = $commission->{'transactionId'};
                $program_id     = $commission->{'advertiserId'};
                $post_date      = $commission->{'postingDate'};
                $action_status  = $commission->{'actionStatus'};
                $amount         = $commission->{'commissionAmount'};
}

An XML response to a SOAP request will be something like:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soap:Body>
        <findPublisherCommissionsResponse xmlns="http://api.cj.com">
            <out xmlns="http://api.cj.com">
                <publisherCommissions xmlns="http://transaction.service.cj.com">
                    <ns1:PublisherCommissionV2 xmlns:ns1="http://transaction.domain.cj.com">
                        <actionStatus xmlns="http://transaction.domain.cj.com">
                            closed
                        </actionStatus>
                        <actionType xmlns="http://transaction.domain.cj.com">
                            sale
                        </actionType>
                        <adId xmlns="http://transaction.domain.cj.com">
                            13123123
                        </adId>
                        <advertiserId xmlns="http://transaction.domain.cj.com">
                            12312312
                        </advertiserId>
                        <advertiserName xmlns="http://transaction.domain.cj.com">
                            Merchant UK ltd
                        </advertiserName>
                        <commissionAmount xmlns="http://transaction.domain.cj.com">
                            25
                        </commissionAmount>
                        <country xmlns="http://transaction.domain.cj.com">
                        </country>
                        <eventDate xmlns="http://transaction.domain.cj.com">
                            2009-08-28T20:30:44-07:00
                        </eventDate>
                        <lockingDate xmlns="http://transaction.domain.cj.com">
                            2009-09-10T00:00:00-07:00
                        </lockingDate>
                        <orderId xmlns="http://transaction.domain.cj.com">
                            1231232
                        </orderId>
                        <original xmlns="http://transaction.domain.cj.com">
                            true
                        </original>
                        <originalActionId xmlns="http://transaction.domain.cj.com">
                            12312321312
                        </originalActionId>
                        <postingDate xmlns="http://transaction.domain.cj.com">
                            2009-08-28T23:30:03-07:00
                        </postingDate>
                        <sId xmlns="http://transaction.domain.cj.com">
                            googlelink
                        </sId>
                        <saleAmount xmlns="http://transaction.domain.cj.com">
                            25
                        </saleAmount>
                        <transactionId xmlns="http://transaction.domain.cj.com">
                            123123123
                        </transactionId>
                        <websiteId xmlns="http://transaction.domain.cj.com">
                            1231231
                        </websiteId>
                    </ns1:PublisherCommissionV2>
                </publisherCommissions>
                <sortBy xmlns="http://transaction.service.cj.com">
                </sortBy>
                <totalResults xmlns="http://transaction.service.cj.com">
                    1
                </totalResults>
            </out>
        </findPublisherCommissionsResponse>
    </soap:Body>
</soap:Envelope>

You maybe having issues parse the xml response into a SimpleXml Object because SimpleXML doesn't like colons (:) in the tag and attribute names SOAP & SimpleXML. Also check here SimpleXML & Namespaces

Your SOAP request should already be an object so I am uncertain as to why you are trying to parse it using SimpleXML. If you need the response as XML then you could always use a serializer.

In my own script as an example I use something like this:

//code here
$cj_devkey = "CJ KEY HERE";

        $ini    = ini_set( "soap.wsdl_cache_enabled", "0" );
        $client = new SoapClient( "https://pubcommission.api.cj.com/wsdl/version2/publisherCommissionServiceV2.wsdl", array(
             'trace' => true,
            'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP,
            'proxy_host' => "proxy" 
        ) );

        $object = $client->findPublisherCommissions( array(
             "developerKey" => $cj_devkey,
            "date" => '08/28/2009',
            "dateType" => 'event',
            "advertiserIds" => '',
            "websiteIds" => '123456',
            "actionStatus" => '',
            "actionTypes" => 'sale',
            "adIds" => '',
            "countries" => 'all',
            "correctionStatus" => 'all',
            "sortBy" => '',
            "sortOrder" => '' 
        ) );

A sample response using print_r($object) will return :

stdClass Object
(
    [out] => stdClass Object
        (
            [publisherCommissions] => stdClass Object
                (
                    [PublisherCommissionV2] => stdClass Object
                        (
                            [actionStatus] => closed
                            [actionType] => sale
                            [adId] => 123123213
                            [advertiserId] => 2313531
                            [advertiserName] => MERCHANT HERE
                            [commissionAmount] => 25
                            [country] => 
                            [eventDate] => 2009-08-28T20:30:44-07:00
                            [lockingDate] => 2009-09-10T00:00:00-07:00
                            [orderId] => 123123
                            [original] => 1
                            [originalActionId] => 123123
                            [postingDate] => 2009-08-28T23:30:03-07:00
                            [sId] => sports
                            [saleAmount] => 25
                            [transactionId] => 12312312
                            [websiteId] => 123123
                        )

                )

            [sortBy] => 
            [totalResults] => 1
        )

)

If you want to traverse the object elements you can use stuff like:

$num_results = $object->out->totalResults;

or loop through each commission payment with stuff like:

foreach ( $object->out->publisherCommissions as $commission ) {
                $user_id        = $commission->{'sId'};
                $transaction_id = $commission->{'transactionId'};
                $program_id     = $commission->{'advertiserId'};
                $post_date      = $commission->{'postingDate'};
                $action_status  = $commission->{'actionStatus'};
                $amount         = $commission->{'commissionAmount'};
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文