如何从委员会连接API - PHP获得报告


How to get reports from Commision Junction API - PHP

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

我试过了:

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。

我自己弄明白了:

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();
}