You are here:  » magic parser in price tapestry


magic parser in price tapestry

Submitted by steveyoung on Thu, 2006-10-12 03:03 in

I am new to php except for using a few simple php scripts in my html. I wanted to access LinkShares Link Locator Direct and thought magic parser would be what I need. Since I also believed I may want to develop a price comparison website and magic parser was included in price tapestry, I purchased it. However, I can't see how to use only magic parser. According to the magic parser manual, I should navigate to the MagicParserTest.php file to see if it is working correctly, but there is no such file included in price tapestry. What files do I need to upload only magic parser and how can I get the MagicParserTest.php to test it with?

Also, you mentioned in one of the posts that "I am putting together an affiliate datafeed to database tutorial that will describe all the steps required [to put a datafeed into a mysql database] which i'm hoping to get online shortly." This is what I need. Is this available yet? If so, where?

Finally, what I want to do is use the magic parser script to parse and save the "GetAllLinks" of the Linkshare Link Locator Direct datafeed to a mysql database. How do I do this? Please see this link for more information: http://www.cumbrowski.com/CarstenC/pdf/Link_Locator_Direct_Guidelines__Affiliate_v2.2.pdf

Any help would be greatly appreciated.

Submitted by support on Thu, 2006-10-12 03:47

Hello Steve,

Firstly, apologies for the confusion. The main Magic Parser script is part of your Price Tapestry distribution. It is in the /includes/ directory, and can be used by copying it into another directory and then using it as per the documentation on this website.

The MagicParserTest.php script is not included with Price Tapestry. However, to make things easier; I have just updated the system so that you can now download the standalone Magic Parser distribution using your Price Tapestry registration code / email address from the following page:

http://www.magicparser.com/download

Regarding the affiliate datafeed to MySQL tutorial; that was effectively what became Price Tapestry. It turned out that the sample code required was so comprehensive that it was a product in its own right, which is why it was "spun off" into its own distribution.

The LinkShare "GetAllLinks" API looks interesting, and MagicParser.php can certainly be used to process the response from LinkShare; however a SOAP library is also required in order to make the request.

I would like to put together some example code for you; but the best way to do it depends upon which PHP version you are running and whether or not you have the SOAP libraries installed. Could you perhaps find out by writing a phpinfo() script...

<?php
  phpinfo
();
?>

If you could run that script, and then copy and paste into a reply the version number, and the "Configure Command" which is the 3rd item shown in the table. That will tell me what libraries you have installed so I can show you the best way to go about it...

Cheers,
David.

Submitted by steveyoung on Thu, 2006-10-12 19:41

Well, I told you I was new to php. Maybe "new" is not a good word to describe my lack of knowledge. According to my cpanel, my php version is 4.4.3. I am not currently using SOAP on my website but could upload NuSoup or whatever you recommend. Does this help at all and what SOAP do you recommend? If you can help me, I would gladly put something on ABestWebs about this because I'm certain there are others as stupid as I who would love to be able to use this feed. I am using a PC with Dreamweaver 8 if that makes any difference.
Thanks again.

Submitted by support on Fri, 2006-10-13 08:09

Hi Steve,

I'll see if I can make it work using NuSOAP. I'm not a LinkShare user so I don't know if i'll have access to the API but i'll take a look for your and see if I can put some example code together for you.

Cheers,
David.

Submitted by steveyoung on Sat, 2006-10-14 15:35

That would be great! The support here is fantastic!

Submitted by support on Mon, 2006-10-16 16:20

Hi Steve,

Bear with me on this one - the API is authenticated and I don't have an account with Linkshare. I'll try and get in touch and see if I can get a developers account or something....

Cheers,
David.

Submitted by steveyoung on Tue, 2006-10-17 12:37

I can supply you with my username and password if that will help. I'll email it to you if you wish. Is the email address the one listed under the "Contact Us" link?

Submitted by steveyoung on Sun, 2006-11-12 20:48

I don't mean to rush you, but you said you'd create it using NuSoap. Had any luck with it yet. Its been over a month now and I've heard nothing. Just checking.

Submitted by support on Mon, 2006-11-13 07:31

Hi Steve,

I'll contact Linkshare again and try to get a developers account. Thank you for the offer of your details but I don't want to be responsible for anything that may happen to your account as a result.

I'll let you know as soon as i've been able to put something together.

Cheers,
David.

Submitted by support on Thu, 2006-11-16 15:56

Hi Steve,

I've now obtained a LinkShare API account and have experimented using it with NuSOAP.

http://dietrich.ganx4.com/nusoap/

NuSOAP is now fully WSDL compliant; which means that it will return results to you as a PHP array so there is no need to use a script like Magic Parser in order to process the results.

However, i've written 3 simple scripts to show you how to get started with the Linkshare API and NuSOAP. The first script displays the links from GetAllLinks directly from the API. The second script shows you how to load those links into MySQL. The third script shows how to display the links from the MySQL database directly.

To get going; first you will need to download and install nusoap into a directory called "nusoap" within the directory in which you will be running these scripts. This is so that the library files can be found in nusoap/lib - see the require() statement to make sure that everything is in the right place.

Secondly, you will need to setup a table called "links" in your database. Give the table the following fields:

id (autoincrement, primary key)
linkUrl (varchar - this will hold the Linkshare URL)
mname (varchar - this will hold the Linkshare Merchant Name)
mid (varchar - this will hold the Linkshare Merchant ID)

In each of the scripts, setup the config variables are required at the top - for instance your linkshare username / password / sid etc. and your database username, password and name. The Linkshare "sid" refers to one of your Linkshare profiles (websites) - and must be obtained from the API support desk.

1. Display Links Directly From API

View Output

linkshare.php:

<?php
  $linkshare_username 
"YOUR_LINKSHARE_USERNAME";
  
$linkshare_password "YOUR_LINKSHARE_PASSWORD";
  
$linkshare_sid "YOUR_LINKSHARE_SID";
  require(
"nusoap/lib/nusoap.php");
  
$client = new soapclient("http://apps.linksynergy.com/ws/services/HomeLink?wsdl",true);
  
$client->setCredentials($linkshare_username,$linkshare_password);
  
$result $client->call("GetAllLinks",array("sid"=>$linkshare_sid));
  foreach(
$result as $link)
  {
    print 
"<p><a href='".$link["linkUrl"]."'>".$link["mname"]."</a></p>";
  }
?>

2. Load Links From API Into MySQL

linkshare_load.php:

<?php
  $linkshare_username 
"YOUR_LINKSHARE_USERNAME";
  
$linkshare_password "YOUR_LINKSHARE_PASSWORD";
  
$linkshare_sid "YOUR_LINKSHARE_SID";
  
$database_username "YOUR_DATABASE_USERNAME";
  
$database_password "YOUR_DATABASE_PASSWORD";
  
$database_name "YOUR_DATABASE_NAME";
  require(
"nusoap/lib/nusoap.php");
  
$client = new soapclient("http://apps.linksynergy.com/ws/services/HomeLink?wsdl",true);
  
$client->setCredentials($linkshare_username,$linkshare_password);
  
$result $client->call("GetAllLinks",array("sid"=>$linkshare_sid));
  
mysql_connect("localhost",$database_username,$database_password);
  
mysql_select_db($database_name);
  
mysql_query("DELETE FROM links");
  foreach(
$result as $link)
  {
    
$query sprintf("INSERT INTO links SET linkUrl='%s',mname='%s',mid='%s'",
        
mysql_escape_string($link["linkUrl"]),
        
mysql_escape_string($link["mname"]),
        
mysql_escape_string($link["mid"]));
    
mysql_query($query);
  }
?>

3. Display Links From MySQL

View Output

linkshare_display.php:

<?php
  $database_username 
"YOUR_DATABASE_USERNAME";
  
$database_password "YOUR_DATABASE_PASSWORD";
  
$database_name "YOUR_DATABASE_NAME";
  
mysql_connect("localhost",$database_username,$database_password);
  
mysql_select_db($database_name);
  
$result mysql_query("SELECT * FROM links");
  while(
$link mysql_fetch_array($result))
  {
    print 
"<p><a href='".$link["linkUrl"]."'>".$link["mname"]."</a></p>";
  }
?>

Hope this helps,
Regards,
David.

Submitted by crounauer on Thu, 2008-07-03 15:38

Hi David,

I wonder if you could once again please point me in the right direction?

I have got this far with this soap request => $response= $oClient->call('searchProduct', $params3);

stdClass Object
(
    [searchProductReturn] => Array
        (
            [0] => stdClass Object
                (
                    [iId] => 2356704
                    [iMerchantId] => 48
                    [sMerchantProductId] => 0415351693
                    [iUpc] => 0
                    [iEan] => 0
                    [iIsbn] => 415351693
                    [sName] => POPULAR AND THE CANONICAL
                    [sDesc] => POPULAR AND THE CANONICAL by
                    [sSpec] =>
                    [sPromo] => This volume ranges from the Second World War to the postmodern, considering issues of the ''popular'' and the competing criteria by which literature has been judged in the later twentieth century.
                    [sBrand] => TAYLOR & FRANCIS LTD
                    [sModel] =>
                    [iCategoryId] => 538
                    [sAwDeepLink] => http://www.awin1.com/pclick.php?p=2356704&a=61612&m=48&platform=cs
                    [sAwThumbUrl] => http://images.productserve.com/thumb/48/2356704.jpg
                    [sAwImageUrl] => http://images.productserve.com/preview/48/2356704.jpg
                    [sCurrency] => GBP
                    [fSearchPrice] => 16.9
                    [fRrpPrice] => 18.99
                    [sDisplayPrice] => GBP16.90
                    [sMd5] =>
                )
            [1] => stdClass Object
                (
                    [iId] => 2357914
                    [iMerchantId] => 48
                    [sMerchantProductId] => 0415262003
                    [iUpc] => 0
                    [iEan] => 0
                    [iIsbn] => 415262003
                    [sName] => Twentieth-Century Caribbean Literature
                    [sDesc] => Twentieth-Century Caribbean Literature by Alison Donnell
                    [sSpec] => New edition
                    [sPromo] => Traces the processes by which a 'history' and canon of Caribbean literature and criticism have been constructed. Focusing on Anglophone writings from across the twentieth century, this title asks what it is that we read when we approach this Literature, how it is that we read it and what pressures may have influenced our choices and approaches.
                    [sBrand] => Taylor & Francis Ltd
                    [sModel] =>
                    [iCategoryId] => 538
                    [sAwDeepLink] => http://www.awin1.com/pclick.php?p=2357914&a=61612&m=48&platform=cs
                    [sAwThumbUrl] => http://images.productserve.com/thumb/48/2357914.jpg
                    [sAwImageUrl] => http://images.productserve.com/preview/48/2357914.jpg
                    [sCurrency] => GBP
                    [fSearchPrice] => 15.11
                    [fRrpPrice] => 17.99
                    [sDisplayPrice] => GBP15.11
                    [sMd5] =>
                )

I am just unsure how to get that info into an array. I have tried this with limited success and would appreciate if you could please guide me further?

  foreach($response as $product)
  {
print_r($product["0"]);
  }

Thanks,
Simon

Submitted by support on Tue, 2008-07-08 09:05

Hi Simon,

As it is a PHP object that is being returned you need to use the object access notation which is -> instead of using [] as you would normally access the components of an array. The array of records looks like it would be:

$response->searchProductReturn

...so you could use this with "foreach" to get each product object, from which you can then access the parameters, for example:

foreach($response->searchProductReturn as $product)
{
  // see all the object fields
  print_r($product);
  // use them like this
  print $product->sName;
}

Hope this helps!
Cheers,
David.