简体   繁体   中英

Anyone successfully using Commission Junction API?

Is anyone successfully using the CJ web services? I just keep getting java.lang.NullPointerException s even though my app is .net (clearly their errors). CJ support doesn't even know what a web service is. I googled and found many people getting this or other errors. Question is: is it a temporary problem or am I doomed to parse manually downloaded reports for eternity?

The specific API I'm trying to use is the daily publisher commission service . Here is the WSDL.

Links:

After a spending many days, this code is working for me.

$client = new SoapClient($cjCommissionUrl,

    array('trace' => 1,
    'soap_version' => SOAP_1_1,
    'style' => SOAP_DOCUMENT,
    'encoding' => SOAP_LITERAL
    ));


$date = '06/23/2010';
    $results = $client->findPublisherCommissions(array(
    "developerKey" => $cjDeveloperKey,
    "date" => $date,
    "dateType" => 'posting',
    "countries" => 'all',
));

I have successfully used CJ's API with PHP, though not this particular WSDL. I am seriously troubled by the lack of documentation and even cannot find any serious programmer using it (all amateurs basically trying to copy-paste). If you have some more experience we may be able to help each other out.

I had written a Python library for retrieving commission info from CJ. Here is the code: https://github.com/sidchilling/commissionjunction-python-lib

Works for me.

create a page cjcall.php forexample

paste this code and do according to your requirement ie keyword , dev id , records per page

include('../../../../wp-load.php');

$stringkeyw=urlencode(get_option('cj_keyword'));
if(get_option('rm_num_products')==''){
$pperkeyword=50;
}else{
$pperkeyword= get_option('rm_num_products');
}//number of products against keyword

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://product-search.api.cj.com/v2/product-search?website-id=".get_option('cj_siteid')."&keywords=".$stringkeyw."&records-per-page=".$pperkeyword."&serviceable-area=US");

curl_setopt($ch, CURLOPT_HEADER,false); 

curl_setopt($ch, CURLOPT_HTTPGET, true); 

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/xml",  "Authorization:".get_option('cj_devid').""));

$result = curl_exec($ch);

create another page and paste the following code to bring xml from this page:

$hurl= home_url();
$homepage = file_get_contents(''.$hurl.'/wp-content/plugins/rapid_monetizer/cronjob/cjcall.php');
$object = simplexml_load_string($homepage);

    foreach($object->products->product as $cjres)
    {
       //do your code with products coming in $cjres
         }

EDIT: First and foremost, you will not get any results back if there are no commissions to report.

I am working with these API's, I have no problem with any of the REST API's, the SOAP API for the daily publisher commission service does not appear to be working. The results from:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:api="https://pubcommission.api.cj.com">
       <soapenv:Header/>
       <soapenv:Body>
          <api:findPublisherCommissions>
             <api:developerKey>*DEVKEY*</api:developerKey>
             <api:date>01/19/2007</api:date>
             <api:dateType>event</api:dateType>
             <api:advertiserIds></api:advertiserIds>
             <api:websiteIds>123456</api:websiteIds>
             <api:actionStatus>all</api:actionStatus>
             <api:actionTypes></api:actionTypes>
             <api:adIds></api:adIds>
             <api:countries></api:countries>
             <api:correctionStatus></api:correctionStatus>
             <api:sortBy>commissionAmount</api:sortBy>
             <api:sortOrder>desc</api:sortOrder>
          </api:findPublisherCommissions>
       </soapenv:Body>
    </soapenv:Envelope>

Which is completely valid and correct, gives me an HTML page back. Your error is probably related to parsing the page as XML.

The results are:

<html>
<head>
<title>Web Services</title>
</head>

<body vlink="#333333" alink="#FFCC33" bgcolor="#FFFFFF" leftmargin="0" marginwidth="0" topmargin="0" marginheight="0">
    <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
            <td background="images/header_bg.gif">
                <a href="http://webservices.cj.com"><img src="images/header.gif" width="600" height="63" border="0" alt="webservices.cj.com" /></a>
            </td>
        </tr>
    </table>



<h3>Latest WSDLs</h3>
<table width=70%><tr><td>
<ul>
  <li>ProductSearchServiceV2.0<a href="wsdl/version2/productSearchServiceV2.wsdl">[wsdl]</a><img src="images/new11.gif"  width="40" height="15"/></li>
  <li>LinkSearchServiceV2.0<a href="wsdl/version2/linkSearchServiceV2.wsdl">[wsdl]</a><img src="images/new11.gif"  width="40" height="15"/></</li>  
  <li>PublisherCommissionService and ItemDetails V2.0<a href="wsdl/version2/publisherCommissionServiceV2.wsdl">[wsdl]</a><img src="images/new11.gif"  width="40" height="15"/></</li>
  <li>RealTimeCommissionServiceV2.0<a href="wsdl/version2/realtimeCommissionServiceV2.wsdl">[wsdl]</a><img src="images/new11.gif"  width="40" height="15"/></</li>
  <li>AdvertiserSearchService<a href="wsdl/version2/advertiserSearchServiceV2.wsdl">[wsdl]</a></li>
  <li>FieldTypesSupportService<a href="wsdl/version2/supportServiceV2.wsdl">[wsdl]</a></li>
</ul>
</td></tr></table>

<h3>Previously Released WSDLs</h3>
For previous versions of the wsdls <a href="old_versions.jsp">click here.</a><p>

<h3>Sign Up</h3>
<ul>
  <li><a href="sign_up.cj">Sign Up</a></li>
</ul>

</body>
</html>

I have sent them an email, and expect a response today. I will confirm with you that this API is still available, it may have been completely replaced by the Real Time publisher commission API.

I can make a user interface for you to lift your curse !!!

To use Daily Publisher Commission Report Service !!

Let me know here if you still need help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM