PDA

View Full Version : Dynamically Create Amazon Links to use your associate id


amykhar
18 Jul 2005, 18:03
This one is in beta gang. Amazon seems to like to change their link style every two minutes.

What it does: It takes any link to Amazon pages on your forum and modifies the link on the fly to use your associate id. This one should make you some money - it generally works very well for my forum around Christmas time.

No screenshots. You know what an Amazon link looks like ;)

I am offereing this one with limited support. I will get it working as well as possible - in other words, correctly transforming as many links as possible. But, I can't promise it will get every link because of differences between the different vbulletin message editors, etc.

Amy

-------------
This hack will always be free, however your donations are kindly accepted and will help towards further development. If you donate, please leave me some info (either your forum site or username at vB.org) so that I can thank you. :)
https://www.vbulletin.org/forum/external/2010/02/12.gif (https://www.paypal.com/xclick/business=amykhar%40yahoo.com&item_name=UserPage+Donation&no_shipping=1&cn=Your+Comments&tax=0&currency_code=USD)

Dan
18 Jul 2005, 18:46
Nice job:) Very good idea! Won't use it but good job :D

bigcurt
18 Jul 2005, 20:18
Good Job Amy

amykhar
18 Jul 2005, 20:22
Good Job Amy

It's been available for 3.0 versions for ages.

amykhar
19 Jul 2005, 03:21
Gang, I just wanted to note that clicking the install button is pretty important with this and other beta hacks. As I fix any little glitches I find as the code runs on my site, I update the code for you and send out update emails. I will ONLY announce these bug fixes in the update emails as my feeble attempt to entice you to click the install button.

Paul M
19 Jul 2005, 07:51
Perhaps I'm missing something very obvious here - but why do you have a seperate file to upload - when all the plugin does is call this file ? Why not just put the code in the plugin ?

amykhar
19 Jul 2005, 14:38
Perhaps I'm missing something very obvious here - but why do you have a seperate file to upload - when all the plugin does is call this file ? Why not just put the code in the plugin ?

Because I am trying to make it so the file is compatible with the 3 and 2 versions because Amazon has changed its links. In addition, I should be able to hook this into private messages as well and keeping the code in one place makes it more maintainable.

Amy

mrplow
19 Jul 2005, 22:30
Downloading to look at :)
I assume I'm gonna have to fiddle to make it work with .co.uk?


edit: What's the standard form for a US link?

Ours are like this: http://www.amazon.co.uk/exec/obidos/ASIN/0007207328/ref=*****/026-3221647-1306012
http://www.amazon.co.uk/exec/obidos/ASIN/PRODUCTCODE/REFCODE/ ?

I don't even know what the last bit is, I assume it's some kind of session thing?

Anyway the codes at the bottom of your file look like they'd work fine with just .com replaced with .co.uk, what do you reckon?

The other ones... ours are like this
http://www.amazon.co.uk/exec/obidos/redirect?tag=*****&creative=6514&camp=1662&link_code=ur1&path=tg/browse/-/283926 (that's DVDs)

Again looks the same. Seems shockingly sensible (i.e. unlikely!) that both sites actually use the exact same code.



Maybe I'll just dive in and try it :o

amykhar
19 Jul 2005, 23:35
That's what I advise. Just dive in and try. :)

question?
21 Aug 2005, 19:21
Nice hack!

amykhar
21 Aug 2005, 19:44
Thank you. :)

dastar
31 Oct 2005, 13:08
Nice mod. It looks like Amazon very recently changed their URL schema though as it seems it's not inserting the affiliate ID like it used too :(

amykhar
31 Oct 2005, 13:58
Again? I get so sick of Amazon changing their links. This is the third time since this mod originally came out for version 2.x

Amy

Juniors
07 Nov 2005, 00:32
If its possible to use it only with the amazon API, then we dont need links and Amazon will give us automatically an image, text...

Maybe you can work on this Plugin so we can use it with the API!?

Thanks a lot

Junior

amykhar
07 Nov 2005, 03:35
Junior, if you can tell me a way to use the amazon api to take a link that somebody arbitrarily posts and change it to use the associate id, I'll gladly do it as long as it doesn't kill performance.

lazyseller
13 Nov 2005, 04:55
is there a way to choose a different hook ? where it automatically makes the link from existing threads ? i notice this works only on newly created threads

Bernd Glasstett
08 Dec 2005, 23:40
I would love to see this hack in a german version too. Any attempt to make this?

lisagauss
14 Dec 2005, 03:36
I would love to see this also work for different affiliate programs, such as linkshare or comission junction. If anyone knows if there is something similar to this for CJ or Link Share, please, please let me know. Thanks.

Zowners
01 Mar 2006, 10:27
Does this version still work?

amykhar
01 Mar 2006, 10:38
It seems to on my site contrary to earlier reports that the link format has changed.

Marv
01 Mar 2006, 16:43
It seems to on my site contrary to earlier reports that the link format has changed.

Amy,
just a short question. Im using this with the german amazon-site. I never noticed a no=sim in the links. What is it for ?

Anyway,..this no=sim becomes to:
http://www.amazon.de/exec/obidos/ASIN/3131476911/ref%3Dnosim/myaccount-id/313-2246395-9169407
and Im asking myself if this link will lead to a conversion..

Any idea - anyone ?

amykhar
01 Mar 2006, 17:17
The nosim means don't show similar products.

daFish
12 Mar 2006, 18:25
First, great hack amykhar.

Second, is there a way to make the changed links permanent?
Because if you edit a posting, it shows the old and unchanged link.

Holidazed
23 Mar 2006, 15:49
This is a great addon Mnykhar. Good job.

Question: I posted a message at http://www.vbulletin.org/forum/showthread.php?p=932722 that is a request along the same lines as this addon. Can you read it please and tell me what you think?

Thanks

amykhar
23 Mar 2006, 18:28
It's not somethng I'm interested in working on, but it's an interesting idea :)

amykhar
29 Mar 2006, 13:20
I just uploaded a new zip file that fixes a problem my users just now reported with hotlinking Amazon images. Why they didn't mention this problem two years ago....

Users :rolleyes:

MikeWarner
16 Apr 2006, 21:45
How about the same thing for ebay?

amykhar
17 Apr 2006, 12:36
mike, I did it for 3.0 and nobody really used it. With very little effort, you could take the old ebay mod and this mod and combine them to have a working ebay mod.

MikeWarner
17 Apr 2006, 12:55
I'll look into it. Thanks.

Tralala
17 Apr 2006, 16:20
I just uploaded a new zip file that fixes a problem my users just now reported with hotlinking Amazon images. Why they didn't mention this problem two years ago....

Users :rolleyes:

I just updated and tested this, unfortunately the fix not working for me.

Text links continue to convert fine to use my associate ID.

But when I use an Amazon image instead, it does not: the URL stays as the original.

What information can I provide that may help troubleshoot this?

Thanks, Amy...

amykhar
17 Apr 2006, 16:43
The image SHOULD stay as the original. If it converts to an associate image, it breaks the image. The link should use your associate id. The image should not.

Tralala
17 Apr 2006, 16:53
The image SHOULD stay as the original. If it converts to an associate image, it breaks the image. The link should use your associate id. The image should not.

It does as you say; the image stays as the original and displays properly.

I am talking about when I replace the text of a link with the product image, so it's clickable.

Like this:

https://www.vbulletin.org/forum/external/2006/04/11.jpg (http://www.amazon.com/gp/product/B000ECQXJQ/ref=pd_qpt_gw_1/102-0904450-6148904?%5Fencoding=UTF8&v=glance&n=468642)


In this case, the Amazon URL is not converted to use my associates ID.

amykhar
17 Apr 2006, 17:27
Ah. I'll have to poke around with that and see what I can do.

ryancooper
28 Apr 2006, 13:17
Another great addition by amy

NSeXcellent
06 May 2006, 13:12
Dumb question, but once this is installed, how do i use it? :)

Bro_Joey_Gowdy
16 May 2006, 00:45
Downloaded and installed in under a minute.

It appears to be working fine for vb 3.5.3.

:banana:

amykhar
16 May 2006, 01:17
hope it makes you wealthy :D

Tralala
16 May 2006, 01:27
I am talking about when I replace the text of a link with the product image, so it's clickable.
...
In this case, the Amazon URL is not converted to use my associates ID.

Ah. I'll have to poke around with that and see what I can do.

Any news on this, Amy? I'd sure appreciate it. We have a "reviews" section where folks are encouraged to present the links as product photos, and compatibility with your hack would be super cool.

amykhar
16 May 2006, 01:51
I honestly haven't had time to look at it. Sorry.

Tralala
16 May 2006, 01:56
I honestly haven't had time to look at it. Sorry.

No problem, thanks for the response nonetheless. :)

dastar
24 May 2006, 16:33
It seems to on my site contrary to earlier reports that the link format has changed.

Actually, the link formatting for some categories did change, but I think this hack still works. Not sure why some categories changed.

Phillip Chapman
24 May 2006, 20:28
Very nice hack. I do have a question for those who have been using it.

Is the hack smart enough to not change a link that already has your associates ID present?

Does this work on old posts or only on messages that are posted after the hack has been installed?

Phillip Chapman
06 Jun 2006, 01:46
Very nice hack. I do have a question for those who have been using it.

Is the hack smart enough to not change a link that already has your associates ID present?

Does this work on old posts or only on messages that are posted after the hack has been installed?

Just wanted to bump this up in case anyone can help answer these questions.

amykhar
06 Jun 2006, 03:31
1. Yes. It won't change your current affiliate links.
2. This version only works on new messages. The 3.0 version worked on all of them. Jelsoft changed the way urls are parsed - hence the change.

Tralala
22 Jun 2006, 15:28
Is anyone else here running Psionic Vision's Advanced Plugin Manager v2?

I ask because when I enable that, "Create Amazon Links" disappears from my list of plugins and I therefore can no longer disable/enable it:

http://www.vbulletin.org/forum/showthread.php?p=952371#post952371

It's completely reproducible here, even on a clean vB 3.5.4 install. Wondering what might be different about amykhar's hack that would cause it to not appear, when using that Advanced Plugin Manager.

daFish
17 Jul 2006, 16:11
Hi there amykhar.

This Add-on is really great, but we're currently in trouble, because there seems to be a new kind of link for amazon.

The link syntax is the following:

http://www.amazon.de/gp/product/B000GJ0IPM/AFFILICODE

This on isn't corrected with your hack, so is there any chance to get this working?

Best regards,
Marcus

amykhar
17 Jul 2006, 18:15
Amazon keeps changing link formats on me. I can't promise I'll get to it any time soon.

StarBuG
20 Oct 2006, 14:02
Are you still supporting this hack?

I run a german forum (3.6.2 -> will this work on 3.6.x too?) and you only replace amazon.com links.
Could you add amazon.de links as well for the replacement?

Maybe you could also provide some infos where you define the links in your hack and how to adapt them ourself.

Would that be possible?

StarBuG

Tralala
21 Oct 2006, 01:31
Could you add amazon.de links as well for the replacement?


This hack does that:

http://www.vbulletin.org/forum/showthread.php?t=119220

Markith
27 Nov 2006, 12:54
does anyone know if this hack still works and is supported by amazon?? will it work with other sites such as buy.com??? Thanks!

amykhar
27 Nov 2006, 12:56
Yes it works. No, it's not supported by Amazon - although they did help me with testing of initial versions. No, it doesn't work for Buy.com

logastro
06 Jan 2007, 20:24
Your plugin works fine on my vBulletin 3.6 forum. Why don't you post it on vB3.6 Add-ons?

masons
19 Mar 2007, 05:29
works perfect on my 3.6.5! awesome!

VietPirates
30 Mar 2007, 09:01
From Amazon

Just as with other ASINs you can also use the format below to build links directly to Unbox products. Simply substitute the corresponding Unbox ASIN for "B000LEIOOY" and your Associates ID for "assocblog-20."

http://www.amazon.com/gp/product/B000LEIOOY/?tag=assocblog-20

Phillip Chapman
05 May 2007, 19:43
I've been using this hack for a long time. Very nice.

I did have a question though. I noticed under my plugin manager that the title of this hack is listed as "vBulletin" instead of "Dynamically Create Amazon Links". Likewise under manage products, this plugin isn't listed at all.

Can this possibly be updated? Thank you Amy for all of your work on this.

dpatel304
07 May 2007, 06:08
I got this working for the most part, however, my referral links have an extra "/" in it.

http://www.amazon.com/exec/obidos/ASIN/B000NHG7CK//ref=nosim/*****-20

right before ref=nos

Is this normal, and will this affect anything?

dpatel304
09 Jun 2007, 23:07
Sorry to bump, but can anyone answer my above post? Thank you.

reteep
05 Sep 2007, 08:53
Same here:

http://www.amazon.de/exec/obidos/ASIN/3934958664//ref=nosim/XXX-21

reteep
05 Sep 2007, 09:16
Ok this is fixing it the additional slash, replace line 59-68 with this:


$messagearray[1][$i] = "http://www.amazon.de/exec/obidos/ASIN".$asin[0]."ref=nosim/" . $associate_id.'"]';
}
elseif(stristr($messagearray[1][$i],"[/url]"))
{
$messagearray[1][$i] = "http://www.amazon.de/exec/obidos/ASIN".$asin[0]."ref=nosim/" . $associate_id."[/url]";
}
else
{
$messagearray[1][$i] = "http://www.amazon.de/exec/obidos/ASIN".$asin[0]."ref=nosim/" . $associate_id;
}

Tralala
09 Sep 2007, 06:43
Ok this is fixing it the additional slash, replace line 59-68 with this:


$messagearray[1][$i] = "http://www.amazon.de/exec/obidos/ASIN".$asin[0]."ref=nosim/" . $associate_id.'"]';
}
elseif(stristr($messagearray[1][$i],"[/url]"))
{
$messagearray[1][$i] = "http://www.amazon.de/exec/obidos/ASIN".$asin[0]."ref=nosim/" . $associate_id."[/url]";
}
else
{
$messagearray[1][$i] = "http://www.amazon.de/exec/obidos/ASIN".$asin[0]."ref=nosim/" . $associate_id;
}



Looks like all that does is replace the amazon.com with amazon.de?
How would that fix the extra slash???

reteep
09 Sep 2007, 09:17
Looks like all that does is replace the amazon.com with amazon.de?
How would that fix the extra slash???

Oh yea sorry, I adapted it for amazon.de. Just change it back to amazon.com, the important part is this here:


/ASIN".$asin[0]."ref=nosim/"


I removed the slash in front of ref

Tralala
09 Sep 2007, 12:43
Gotcha, thanks!

Didi R.
18 Sep 2007, 18:25
Thx a lot. Great addon. works perfect!

Alfa1
18 Sep 2007, 20:54
Does this addon work out of the box or does it need code modification?

weeno
19 Nov 2007, 03:52
1. Yes. It won't change your current affiliate links.
2. This version only works on new messages. The 3.0 version worked on all of them. Jelsoft changed the way urls are parsed - hence the change.

Is there no way to make this parse posts while they are being rendered/displayed to replace links on-the-fly? I'm not that familiar with hook locations, but it seems this code could be run right before the post is displayed by showthread.

edit:
oh wait.... this may be an old post... looks ilke it does work on existing posts. right?

arn

felxi
20 Nov 2007, 14:26
I made some different fixes and this script works now with vBulletin 3.6.8. The code is not the best but seems to work much better. E.g. [ url=xxx]yyy[ /url] links will be replaces correctly. problems with missing tags like [/font][/size] behind the amazon link will be solved. there can also be an image in the post and the link will be replaced and some other small fixes.

new code for vB 3.6.8

<?php
function process_amazon_links($message) {
// Convert any amazon links to use your affilliate id.
// enter your associate id here
$associate_id = "your-id-here";

if(preg_match_all("/(\"\])/",$message,$tagarray)) {
for($i=0;$i<count($tagarray[1]);$i++) {
$tagarray[1][$i] = $tagarray[1][$i]." ";
}
$message = str_replace($tagarray[0],$tagarray[1],$message);
}

$message = str_replace('', '', $message);
$message = str_replace(' (', '+)?amazon.de\/\S+)/", $message, $messagearray)) {
for($i=0;$i<count($messagearray[1]);$i++) {
if(!stristr($messagearray[1][$i],"$associate_id") && strpos($messagearray[1][$i], '[img]') === false && strpos($messagearray[1][$i], '[IMG]') === false) {
$strippedurl = preg_split("/\/[a-zA-Z0-9]{3}-[a-zA-Z0-9]{7}-[a-zA-Z0-9]{7}/", $messagearray[1][$i]);
$messagearray[1][$i] = $strippedurl[0].$strippedurl[1];

// Look for an asin number
if(!preg_match("/\/[a-zA-Z0-9]{10}\//", $messagearray[1][$i],$asin)) {
if(stristr($messagearray[1][$i],"http://www.amazon.de/exec/obidos/")) {
$strippedurl = preg_split("/http:\/\/www.amazon.de\/exec\/obidos\//",$messagearray[1][$i]);
$messagearray[1][$i] = $strippedurl[0].$strippedurl[1];
}

if(stristr($messagearray[1][$i],"")) {
$strippedurl = preg_split("/\[\/URL\]/",$messagearray[1][$i]);
$messagearray[1][$i] = $strippedurl[0].$strippedurl[1];
$messagearray[1][$i] = "http://www.amazon.de/exec/obidos/redirect?link_code=ur2&camp=1789&tag=".$associate_id."&creative=9325&path=".urlencode(str_replace('[/URL]', '', $messagearray[1][$i]))."[/URL]";
} else {
$messagearray[1][$i] = "http://www.amazon.de/exec/obidos/redirect?link_code=ur2&camp=1789&tag=".$associate_id."&creative=9325&path=".urlencode($messagearray[1][$i]);
}
} else {
if(stristr($messagearray[1][$i],'"]')) {
$bracketarray[0]='"]';
$bracketarrayrep[0] = '"] ';
$messagearray[1][$i]= str_replace($bracketarray,$bracketarrayrep,$messagearray[1][$i]);
$messagearray[1][$i] = "http://www.amazon.de/exec/obidos/ASIN".$asin[0]."ref=nosim/" . $associate_id.'"]';
} elseif(stristr($messagearray[1][$i],"[/URL]")) {
$messagearray[1][$i] = "http://www.amazon.de/exec/obidos/ASIN".$asin[0]."ref=nosim/" . $associate_id."[/URL]";
} else {
$messagearray[1][$i] = "http://www.amazon.de/exec/obidos/ASIN".$asin[0]."ref=nosim/" . $associate_id;
}
}


if($pos = strpos($messagearray[0][$i], '[/URL]')) {
$ext_str = substr($messagearray[0][$i], $pos+6);
if(strpos($messagearray[1][$i], $ext_str) === false) {
$messagearray[1][$i] .= $ext_str;
}
}

if(preg_match('/\](.*)\[\/URL\]/', $messagearray[0][$i], $out)) {
$messagearray[1][$i] = substr_replace($messagearray[1][$i], $out[0], strpos($messagearray[1][$i], '[/URL]'), 6 );
}
}
}
}

$message=str_replace($messagearray[0],$messagearray[1],$message);
return $message;
}
?>

please let me know if u have some problems. dont forget to replace amazon.de with amazon.com.

weeno
22 Nov 2007, 03:21
I made some different fixes and this script works now with vBulletin 3.6.8. The code is not the best but seems to work much better. E.g. [ url=xxx]yyy[ /url] links will be replaces correctly. problems with missing tags like [/font][/size] behind the amazon link will be solved. there can also be an image in the post and the link will be replaced and some other small fixes.


Hi, thanks for posting.

You code, however, does not appear to work for

[URL="http://www.amazon.com/Logitech-970155-0403-V20-Notebook-Speakers/dp/B0009WKBGC"]these[/URL]

results in...

[url="http://www.amazon.com/exec/obidos/redirect?link_code=ur2&camp=1789&tag=AFFILIATECODE&creative=9325&path=http%3A%2F%2Fwww.amazon.com%2FLogitech-970155-0403-V20-Notebook-Speakers%2Fdp%2FB0009WKBGC%22%5D these[/URL]

felxi
22 Nov 2007, 21:42
I rewrote this modification completely within the last hours.

have a look at:
http://www.vbulletin.org/forum/showthread.php?t=163393

Coop1979
07 Feb 2009, 04:15
I just PM'd the coder. I offered financial compensation to update the mod, so hopefully that will help!

wraggster
22 Mar 2011, 11:07
ok got this working nicely in VB3.8.7 for amazon UK

basically did this

<?php

function process_amazon_links($message)
{


// Convert any amazon links to use your affilliate id.

// enter your associate id here

$associate_id = "dcemu-21";

if(preg_match_all("/(\"\])/",$message,$tagarray))
{
for($i=0;$i<count($tagarray[1]);$i++)
{
$tagarray[1][$i] = $tagarray[1][$i]." ";
}
$message=str_replace($tagarray[0],$tagarray[1],$message);
}
if(!preg_match_all("/(\[img\S+)/",$message,$messagearray)){
if(preg_match_all("/(http:\/\/[A-z0-9\.]+amazon.co.uk\/\S+)/",$message,$messagearray))
{

for($i=0;$i<count($messagearray[1]);$i++)
{
if(!stristr($messagearray[1][$i],"$associate_id"))
{
$strippedurl = preg_split("/\/[a-zA-Z0-9]{3}-[a-zA-Z0-9]{7}-[a-zA-Z0-9]{7}/", $messagearray[1][$i]);
$messagearray[1][$i] = $strippedurl[0].$strippedurl[1];
// Look for an asin number
if(!preg_match("/\/[a-zA-Z0-9]{10}\//", $messagearray[1][$i],$asin))
{
if(stristr($messagearray[1][$i],"http://www.amazon.co.uk/exec/obidos/"))
{
$strippedurl = preg_split("/http:\/\/www.amazon.co.uk\/exec\/obidos\//",$messagearray[1][$i]);
$messagearray[1][$i] = $strippedurl[0].$strippedurl[1];
}

if(stristr($messagearray[1][$i],"[/url]"))
{
$strippedurl = preg_split("/\[\/url\]/",$messagearray[1][$i]);
$messagearray[1][$i] = $strippedurl[0].$strippedurl[1];
$messagearray[1][$i] = "http://www.amazon.co.uk/exec/obidos/redirect?link_code=ur2&camp=1789&tag=".$associate_id."&creative=9325&path=".$messagearray[1][$i]."[/url]";
}
else
{
$messagearray[1][$i] = "http://www.amazon.co.uk/exec/obidos/redirect?link_code=ur2&camp=1789&tag=".$associate_id."&creative=9325&path=".$messagearray[1][$i];

}
}
else
{
if(stristr($messagearray[1][$i],'"]'))
{
$bracketarray[0]='"]';
$bracketarrayrep[0] = '"] ';
$messagearray[1][$i]= str_replace($bracketarray,$bracketarrayrep,$messagearray[1][$i]);
$messagearray[1][$i] = "http://www.amazon.co.uk/exec/obidos/ASIN".$asin[0]."/ref=nosim/" . $associate_id.'"]';
}
elseif(stristr($messagearray[1][$i],"[/url]"))
{
$messagearray[1][$i] = "http://www.amazon.co.uk/exec/obidos/ASIN".$asin[0]."/ref=nosim/" . $associate_id."[/url]";
}
else
{
$messagearray[1][$i] = "http://www.amazon.co.uk/exec/obidos/ASIN".$asin[0]."/ref=nosim/" . $associate_id;
}
}

}
}
}
$message=str_replace($messagearray[0],$messagearray[1],$message);
}
return $message;
}


?>



you can use this plugin for amazon uk and http://www.vbulletin.org/forum/showthread.php?t=163393 for amazon usa at same time, works a treat.

insidegames
20 Feb 2012, 16:29
is their a way to get this works under vBulletin 4.1.10?

kisanjong
05 Mar 2012, 08:33
is their a way to get this works under vBulletin 4.1.10?

also interested in this :)

4.1.11

Thanks