andy's php projects
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Script and site usage:
All of the scripts on this site are provided free for non-commerical, personal or non-profit use. If you find these scripts useful to you, appreciate the free support, or are just an all round nice person, then why not donate a little dosh? If you wish to use any of these in a commercial system, please refer to the payment plan.


New class version

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> CafePress Box
View previous topic :: View next topic  
Author Message
VisiGod
Newbie


Joined: 27 Jan 2004
Posts: 3

PostPosted: Fri Mar 17, 2006 5:55 am    Post subject: New class version Reply with quote

Hello Andy,

Is there any update on the cafepress class version. The current one no longer works.

I've looked at the code and it seems that the preg_match isnt matching tha cpPattern.
Back to top
View user's profile Send private message
Goosemoose
Newbie


Joined: 23 Mar 2006
Posts: 2

PostPosted: Thu Mar 23, 2006 8:31 pm    Post subject: broken Reply with quote

I'm also having a problem. I noticed the example on this site no longer works anymore. Anyone have an idea? Thanks!
Back to top
View user's profile Send private message Visit poster's website
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Fri Mar 24, 2006 1:07 pm    Post subject: Reply with quote

Thanks for letting me know about this! I rarely go to CafePress.com any more so don't know when they change things.

The problem was just that the image path had changed, but here's a quick fix until I roll out a proper release (which'll hopefully be today).

Change the regular expression to look like this:

Code:
$this->cpPattern = "<td align=\"center\" valign=\"top\"><p><a href=\"\\/{$this->storeID}\\.(\\d+)\"><img class=\"imageborder\" border=\"0\" height=\"150\" alt=\"([^\"]*)\" src=\"([^\"]*)\"><\\/a><br><br><a href=\"\\/{$this->storeID}\\.(\\d+)\">(.*?)<\\/a><br>\\$([^<]*)<\\/td>";


Then, as I changed the pattern a little, change the required block in getProducts() to look like this:

Code:
if (preg_match("/{$this->cpPattern}/i", $line, $matches)) {
    $this->products[$matches[1]]['description'] = trim($matches[2]);
    $this->products[$matches[1]]['image'] = trim(basename($matches[3]));
    $this->products[$matches[1]]['image_url'] = trim($matches[3]);
    $this->products[$matches[1]]['price'] = trim($matches[6]);
}
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Andelos
Newbie


Joined: 26 Mar 2006
Posts: 3
Location: Denver

PostPosted: Sun Mar 26, 2006 2:09 am    Post subject: Thank you!!! Reply with quote

For the fix.
Back to top
View user's profile Send private message Visit poster's website
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Mon Mar 27, 2006 9:48 am    Post subject: Reply with quote

No problem!

If anyone's running into problems after upgrading the class, such as no products being gathered, then try removing the files from your cache directory (or turning off caching) and try again.

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Goosemoose
Newbie


Joined: 23 Mar 2006
Posts: 2

PostPosted: Fri Mar 31, 2006 12:58 am    Post subject: Thanks! Reply with quote

Worked perfectly. Thanks for the help.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> CafePress Box All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group