- 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:
changes to (there should be no spaces after "item"):
Another example:
changes to:
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:
changes to:
"tag=domainspring-20" in the above code is my referral code.
However, a URL like:
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
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:
















