Thread: Web Services Beginner Desperation |
|

October 26th, 2007, 08:10 AM
|
|
Full Member
Join Date: January 17th, 2005
Posts: 208
|
|
I just spent hours searching for an elementary tutorial on how to get products from CJ merchants via Web services. I have a developer key, and my web server is using PHP 5.2.
It seems the most basic point is ignored in all of them. And that is:
What files do I need to create and where do I need to put them?
I am new to these kind of applications, and need the ABC's. I've seen the tutorials explaining how to shape the soap API query and all that. That doesn't scare me. But how do you make it happen?
1. What files send the query
2. Receive the response
3. Format it so I can do something with it.
Thanks!
|

October 26th, 2007, 08:39 AM
|
|
Grandma broke her coccyx!
Join Date: May 8th, 2007
Location: North Carolina
Posts: 2,242
|
|
I don't use the CJ web services, but I found this from a while ago when I was playing with it a little. You may find it helpful as a example, but keep in mind I worked on this in 11/2006. If you need something explained in this code, I will do my best to answer.
Code:
// parameters defined
$developerkey = "";
$websiteIdx = "";
$advertiserIds = "joined";
$keywords = "''";
$serviceableArea = "''";
$upcOrIsbnOrEan = "''";
$manufacturerName = "''";
$advertiserSku = "''";
$lowPrice = "''";
$highPrice = "''";
$currency = "''";
$sortBy = "''";
$orderIn = "''";
$startAt = 0;
$maxResultsx = 100;
// create a instance of the SOAP client object
$soapclient = new soapclient("http://api.cj.com/wsdl/productSearchService.wsdl", 'wsdl');
// set up an array containing input parameters to be passed to the remote procedure
$params = array(
"developerKey" => $developerkey,
"websiteId" => $websiteIdx,
"advertiserIds" => $advertiserIds,
"keywords" => $query,
"serviceableArea" => "",
"upcOrIsbnOrEan" => "",
"manufacturerName" => "",
"advertiserSku" => "",
"lowPrice" => "",
"highPrice" => "",
"currency" => "",
"sortBy" => "",
"orderIn" => "",
"startAt" => $startAt,
"maxResults" => $maxResultsx
);
// create a proxy so that WSDL methods can be accessed directly
$proxy = $soapclient->getProxy();
// invoke the method
$result = $proxy->search($params);
// Count how many arrays returned when searching product
$a = $result['searchReturn']['products']['products'];
$count = count($a);
echo "Results: " . $count . " ";;
// Get the total number of search results for the query
$total_itemsx = $result['searchReturn']['totalPossible'];
//Loop through the array or returned products
for($i = 0;$i < $count; $i++) {
$advertiser_id = $result['searchReturn']['products']['products'][$i]['advertiserId'];
$advertiser_name = $result['searchReturn']['products']['products'][$i]['advertiserName'];
$click_url = $result['searchReturn']['products']['products'][$i]['clickUrl'];
$currency = $result['searchReturn']['products']['products'][$i]['currency'];
$description = $result['searchReturn']['products']['products'][$i]['description'];
$image_url = $result['searchReturn']['products']['products'][$i]['imageUrl'];
$name = $result['searchReturn']['products']['products'][$i]['name'];
$price = $result['searchReturn']['products']['products'][$i]['price'];
$sku = $result['searchReturn']['products']['products'][$i]['sku'];
$upc = $result['searchReturn']['products']['products'][$i]['upc'];
} // close the loop
|

October 26th, 2007, 08:45 AM
|
|
Full Member
Join Date: January 17th, 2005
Posts: 208
|
|
Thanks a lot, I'll look into this, as it makes sense.
But my question is even more basic - where does this go?
Is it on the web page? Is this a separate php? Do you see what I'm asking here?
|

October 26th, 2007, 08:51 AM
|
|
Member
Join Date: July 18th, 2006
Posts: 92
|
|
Quote:
|
Originally Posted by hazlcha
Is it on the web page? Is this a separate php? Do you see what I'm asking here?
|
It goes where ever you want to use it and that is up to you.
How do you expect to use it?
|

October 26th, 2007, 08:52 AM
|
|
Grandma broke her coccyx!
Join Date: May 8th, 2007
Location: North Carolina
Posts: 2,242
|
|
Quote:
|
Originally Posted by hazlcha
Thanks a lot, I'll look into this, as it makes sense.
But my question is even more basic - where does this go?
Is it on the web page? Is this a separate php? Do you see what I'm asking here?
|
Many choices on that, but I just slapped this within a webpage and loaded the page. I was just sending the ourput of the call to the page so I could see if it was working.
|

October 26th, 2007, 09:23 AM
|
|
Full Member
Join Date: January 17th, 2005
Posts: 208
|
|
OK, so it should work from anywhere. I will go try that, and report back tomorrow.
Thank you kind sirs!
:-)
|
 |

Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is On
|
|
|
|
|