PHP Help Needed (String Manipulation) 100 NB Awarded

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Watch

DomainSpring

Established Member
Impact
1
PHP Help Needed (String Manipulation) 100 $NB Awarded

Hi,

Can someone please help me with some PHP string manipulation? I will award 100 NameBucks to the first person who sends me quality code that works correctly (post "DONE" and PM me the code). Basically, I will be passing in a random URL, and if it is from eBay or amazon.com, the string/URL needs to be changed to include referral code. The eBay one should be easier:

For example:

Code:
http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&category=11153&item=5718385022

changes to (there should be no spaces after "item"):

Code:
http://www.qksrv.net/click-1549868-5463217?loc=http%3A//cgi.ebay.com/ws/eBayISAPI.dll%3FViewItem%26category%3D11153%26item%3D5718385022

Another example:

Code:
http://search.ebay.com/_W0QQtZvb?ssPageName=h:h:fitem:US

changes to:

Code:
http://www.qksrv.net/click-1549868-5463217?loc=http%3A//search.ebay.com/_W0QQtZvb%3FssPageName%3Dh%3Ah%3Afitem%3AUS

So, basically, it looks like you will have to check that "ebay.com" is in the string/URL, and if so, take the whole string/URL, URLencode it, and append it after "http://www.qksrv.net/click-1549868-5463217?loc="

Amazon examples:

Code:
http://www.amazon.com/exec/obidos/tg/detail/-/B00019PD0W/qid=1094262263/sr=8-1/ref=pd_ka_1/002-2456420-8213624?v=glance&s=music&n=507846

changes to:

Code:
http://www.amazon.com/exec/obidos/redirect?tag=domainspring-20&path=tg/detail/-/B00019PD0W/qid%3D1094262263/sr%3D8-1

"tag=domainspring-20" in the above code is my referral code.

However, a URL like:

Code:
http://www.amazon.com/exec/obidos/ASIN/B0000X5RTG/domainspring-20

should be left alone (I will go ahead and say anything with "/ASIN/")

Of course, for both of these sites, it's important that no URLs that already have a referral code already (like the example above) get modified (probably into something messy). Confused much? :blink: PM me with any questions or if you need more examples - perhaps someone that has Amazon Associates experience can let me know of any other potential snafus.

Thanks!
Cary
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Don't need NameBucks. Try this (You might have to modify the amazon match string if you have different amazon urls.) :

PHP:
PM sent

E.g.: echo changed("http://www.amazon.com/exec/obidos/tg/detail/-/B00019PD0W/qid=1094262263/sr=8-1/ref=pd_ka_1/002-2456420-8213624?v=glance&s=music&n=507846");
 
Last edited:
0
•••
Thanks for getting back to me alien :] Can you just add something that checks for "amazon.com" instead of just checking for the "tg" and "/ref" (I believe that is what the code checks). I'll be happy to send you the $100NB as promised. B-)
 
Last edited:
0
•••
:blink:
 
Last edited:
0
•••
Hi,

Yes, I was eluding to the top version, with the combined solution (although that code seems to only return $am). If you can figure out what is wrong with that, I'd appreciate it. I am sending over the $NB now. Thanks for your efforts and kindness B-)

Cary
 
Last edited:
0
•••
:blink:
 
Last edited:
0
•••
Dynadot — .com TransferDynadot — .com Transfer
Appraise.net

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back