Commission Junction API - SOAP problems

Discussion in 'PHP' started by lv211, Aug 29, 2007.

  1. #1
    I'm trying to get the commission junction product search code up and running. I had problems initially so I deleted some of the code. As of right now I get the error
    I think it might have something to do with the wsdl file since it does not recognize the search function.

    I'm using 1and1 as a host and I am using php5. Their server does not have SOAP installed so I am using NuSoap.

    Any help or insight is greatly appreciated.

    //This file requires PHP version 5.0 or later
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    	<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    	<title>Product Search</title>
    	<style type="text/css" media="screen">
    	/* <![CDATA[ */
    		#results {
    		        margin: auto 0;
    		        padding: 20px;
    		}
    
    		#results a {
    		        text-decoration: none;
    		        padding: 10px;
    		        margin: 10px;
    		        display: table;
    		        border: 1px solid #fff;
    		}
    
    		#results a:hover {
    		        text-decoration: none;
    		        border: 1px solid #000;
    		 }
    
    		#results img {
    		        float: left;
    		        border: 1px solid black;
    		}
    
    		#results p {
    		        margin-left: 100px;
    		}
    	/* ]]> */
    	</style>
    
    </head>
    <body>
    
            <center>
            <h2>Commission Junction Demo Product Search</h2>
    	<form action="<?php echo $_SERVER['PHP_SELF']  ?>" method="get">
    		<p><label for="keywords">Search for </label>
    		<input type="text" name="keywords" value="<?php echo $_GET['keywords'] ?>" >
    		<input type="submit" value="Continue &rarr;" /></p>
    	</form>
    	</center>
    	<hr>
    	<?php
    
    	        require_once("../lib/nusoap.php");
    
    	        // create a soap client using the Commission Junction WSDL
    	        $ini = ini_set("soap.wsdl_cache_enabled","0");
                  $client = new SoapClient('http://api.cj.com/wsdl/literal_wrapped/productSearchService.wsdl', array('trace' => true));
    
                    // call the service with the appropriate variables, remember developer key is required
                    $results = $client->search(
                            $developerKey = 'asdfkj...',
                            $websiteId = '',
                            $advertiserIds ,
                            $keywords  = $_GET['keywords'],
                            $serviceableArea ,
                            $upcOrIsbnOrEan ,
                            $manufacturerName ,
                            $advertiserSku ,
                            $lowPrice ,
                            $highPrice ,
                            $currency ,
                            $sortBy ,
                            $orderIn ,
                            $startAt = 0,
                            $maxResults = 10
                            );
    
                    // give the user a nice message about the results
                    print "<h3>Your search for '$keywords' generated $results->totalPossible results</h3>";
    
                    // iterate through the results and display them to the user
                    echo '<div id="results">';
                    foreach ($results->products as $product) {
                            // format the price so that it is consistant
                            $price = sprintf('%01.2f', $product->price);
                            echo "<a href='$product->clickUrl'><img src ='$product->imageUrl' height='70' ><p>$product->name <br/> Offered by $product->advertiserName at <b>$price ($product->currency)</b> </p></a>";
                            echo "<div style='clear:both'></div>";
                            }
                    echo '</div>';
    
                    // if something goes wrong show the user a nice message
                    
            ?>
    
    </body>
    </html>
    
    Code (markup):

     
    lv211, Aug 29, 2007 IP