Eep, 300 views, not a single response :scared, I'll keep my code to myself I think.
Code removed because of hit'n'run
The trouble with the rat race is that even if you win you're still a rat.
Time passes. Listen. Time passes. Dylan Thomas
Ebay Alerts to your inbox
Eep, 300 views, not a single response :scared, I'll keep my code to myself I think.
The trouble with the rat race is that even if you win you're still a rat.
Time passes. Listen. Time passes. Dylan Thomas
Ebay Alerts to your inbox
HI script Id be interested in the script. Im just looking for a niche at the moment. :tup
Click Them and they Might Come
No need to get touchy about it ? don't know what the script is, don't know what you're on about, don't therefore know why you posted in the first place.. ?
You're right of course :blush, I posted the code to a script that interacts with cj's webservice and displays product from their extensive database in php pages. It works really well, and, I was a little grouchyafter thinking that I'd supplied lurkers with valuable code, with not a single comment or thanks, so I removed it.
Panties are no longer in a bunch :tup
Code is available on request![]()
The trouble with the rat race is that even if you win you're still a rat.
Time passes. Listen. Time passes. Dylan Thomas
Ebay Alerts to your inbox
Hi Scriptmonkey,
I just saw your post. Sorry for the delay in our response.
Thank you for taking an interest in our Webservices and creating a script. Although we've not tested the functionality yet, we love the fact that developers are interacting with Webservices.
I would like to talk to you a bit more about your efforts and how we can open them up to the community. When you get a chance, drop me a line to talk further.
Thank you,
Daniel Powel
dpowel@cj.com
0208 785 5825
Save the following as a php page and call it with as many or as few of the variables as you want.
Coming soon, CJ Wordpress plugin
PHP Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
}
.centralproducts {
width:310px;
margin: 5px;
padding:2px;
display:inline-block;
float:left;
min-height:200px;
height:200px;
overflow:hidden;
border:1px solid #000033;
background-color:#FFFFFF
}
.centralproducts img{
border:none;
float:left;
margin:5px;
}
-->
</style>
</head>
<body>
<?php
ini_set("soap.wsdl_cache_enabled", "1");
//Variables
// keywords = 'q' defaults to white ( whitespace must be encoded as + and + must be encoded as %2B )
// currency = 'c' defaults to GBP
// number of results = 'n' defaults to 10
// advertisers = 'a' defaults to all joined
// startat = 's' defaults to 0
//sortBy = 'sb' defaults to price valid values are 'price | name | advertiserName | advertiserId | manufacturerName'
//sortorder = 'so' defaults to ascending valid values 'asc | desc'
$developerKey = "YOUR DEVELOPER KEY";
$websiteId = "YOUR CJ SITE ID";
$keywords = "white";
if (isset($_GET['q'])) {
$keywords = $_GET['q'];
}
$number = "10";
if (isset($_GET['n'])) {
$number = $_GET['n'];
}
$advertiser = "joined";
if (isset($_GET['a'])) {
$advertiser = $_GET['a'];
}
$startAt = "0";
if (isset($_GET['s'])) {
$startAt = $_GET['s'];
}
$currency = "GBP";
if (isset($_GET['c'])) {
$currency = $_GET['c'];
}
$sortBy = "price";
if (isset($_GET['sb'])) {
$sortBy = $_GET['sb'];
}
$sortorder = "asc";
if (isset($_GET['so'])) {
$sortorder = $_GET['so'];
}
$client = new SoapClient("https://product.api.cj.com/wsdl/version2/productSearchServiceV2.wsdl", array('trace'=> true));
$results = $client->search(array("developerKey" => $developerKey,
"websiteId" => $websiteId,
"startAt" => $startAt,
"maxResults" => $number,
"keywords" => $keywords,
"currency" => $currency,
"lowPrice" => '0.5',
"sortBy" => $sortBy,
"sortOrder" => $sortorder,
"advertiserIds" => $advertiser));
foreach($results->out->products->Product as $details){
$image = $details->imageUrl;
$id = $details->sku;
$name = $details->name;
$merchantlink = $details->buyUrl;
$price = $details->price;
$description = $details->description;
$advertiserName = $details->advertiserName;
echo "<div class=\"centralproducts\"/><a href=".$merchantlink." title=\"".$name."\"><img src=\"".$image."\" width=\"100\" alt=\"".$name."\" /></a><b>".$advertiserName."</b><br/><br/><b>".str_replace(''','\'',$name)."</b><br/><br/>".substr($description,0,400)."...<br/><font color=\"red\">£".$price."</font></div>";
}
$thecount = $results->out->totalResults;
//echo "<div style=\"clear:both;\"/><pre>";
//print_r($results);
//echo "</pre>";
?>
</body>
</html>
The trouble with the rat race is that even if you win you're still a rat.
Time passes. Listen. Time passes. Dylan Thomas
Ebay Alerts to your inbox
Hi Scriptmonkey - thanks for a great cool script (yet again!) :tup
Just thought I'd give you some feedback which will hopefully help everyone....
Here's the default CJ script in action - which works fine and dandy (apart from the price display).
However, if I change the keywords variable to "Lego" I get this output and if I change the keywords variable to "dinosaur" I get this output :scared
I suspect they latter results/errors are to do with the lack of merchants I've signed up to which offer such "products" or not as the case may be
Please don't think I'm being negative about your script - far from it - I'm just hoping my feedback will help iron out any creases![]()
Hi D, and thanks
Oddly enough I get the same errors, but, I'm not signed up to many merchants with the developer id that I use. I don't think for instance that argos products are filtering through into this system
I've kind of abandoned that script now, as cj's webservice isn't as reliable as it needs to be for me to create anything around it.
BTW you can just use the querystring like so
Commission Junction Script by scriptmonkey
etc. without having to change the code in the page
as for the price thing, it just needs a number_format on it like so
replace
£".$price."
with
£".number_format($price,2,'.',',')."
The trouble with the rat race is that even if you win you're still a rat.
Time passes. Listen. Time passes. Dylan Thomas
Ebay Alerts to your inbox
Thanks for the tips and extra code scriptmonkey - worked a treat :tup
Having tested things further, the old "Warning: Invalid argument supplied for foreach()" error seems to crop up when you use a keyword that doesn't exist in the CJ webservice :td
It's a shame that the webservice appears to be so flaky really
Still, its been a useful learning exercise for me![]()
It was more of an example code than a production thing, but, that error is basically where the for each loop is trying to run through an array that is empty.
I think that the webservice was built with data retrieval into a database uppermost in the developers mind, so, for using in a live environment it's not really appropriate, unless of course the results were cached.
There's always the possibility of it being a GIGO error, sometimes my coding isn't as shiny as it should be :scared
I'll have another look at the documentation tonight or tomorrow, and see if theres any further parameters that could be sent in the request to get around that error, or more likely, write a proper error handler for it :blush and a caching routine.
The trouble with the rat race is that even if you win you're still a rat.
Time passes. Listen. Time passes. Dylan Thomas
Ebay Alerts to your inbox
Azam.net (19-06-09)
I usually do CJ WS in this way. I run a script which query cj ws by keyword --> store the data in xml file --> convert it to mysql --> use another script to call the data in wordpress. may be you don't need to save the data in xml file, you can just save them directly in mysql, but i got some reason to do it in that way.
If it do it in this way, I think it's more reliable than querying the cj ws directly. :tup
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks