0

Commission Junction 是附属公司的名称。我一般不熟悉 SOAP、WSDL 和 Web 服务,但想快速测试从他们的附属 api 返回的数据。不能让它工作。他们为他们的API提供了一个页面

我试过 smtg 喜欢:

public function testCJApi() {

    $url = "http://" . $this->user . ":" . $this->password . "@datatransfer.cj.com/datatransfer/files/" . $this->account . "/outgoing/commission_report.csv";

    $xml = simplexml_load_file($url);

    if (isset($xml)) {
        return ($xml
            ? $this->formatJsonReturn($xml, array("txt"=>"CJ Results OK","code"=>""))
            : $this->formatJsonReturn("", array("txt"=>"CJ Results Empty","code"=>""))
        );
    }
}

但它没有给我任何结果。我只需要快速测试返回的数据。他们提供的 API 链接是 http://api.affiliatewindow.com/v4/MerchantService?wsdl

4

1 回答 1

0

我自己想通了:

public function testCJApi() {

    $uri = "https://commission-detail.api.cj.com/v3/commissions?date-type=posting&start-date=2013-02-15&end-date=2013-02-17"; // can be other api uri, this is one of them

    $context = stream_context_create(
        array(
            'http' => array(
                'method' => 'GET',
                'header' => 'Authorization: ' . 'YOUR API KEY GOES HERE'
            )
        )
    );
    $x = file_get_contents($uri, false, $context);
    $response = new SimpleXMLElement($x);
    return $response->asXML();
}
于 2014-06-02T10:10:29.137 回答