Linkcode Decoding
From TMM Wiki
Revision as of 15:52, 23 June 2010 by TMMStephenY2 (talk | contribs) (Created page with '{{NATS3 Manual | show_sites_admin_section = true }} If you want to manually encode or decode a NATS3 link code, you will need to use a custom PHP script in order to do this.…')
If you want to manually encode or decode a NATS3 link code, you will need to use a custom PHP script in order to do this. Including NATS functions for encoding or decoding a link code will create unnecessary overhead. You would also only be able to run the NATS functions on the NATS server. Instead of using a NATS function here, we recommend that you use a custom script, such as the ones in the following examples.
Decoding a Link
You can use this example PHP script to decode NATS link codes.
<? $data = "MjE3OjY6MTE"; if($argv[1]) $data = $argv[1]; $chars = strlen($data); $add = 4 - ($chars % 4); if ($add < 4) while($add--) $data .= '='; list($campaign, $program, $site) = explode(':', base64_decode($data)); echo "Campaign: $campaign \nProgram: $program \nSite: $site \n\n"; ?>
Encoding a Link
You can use this example PHP script to encode NATS link codes.
<? $campaignid = '38'; $programid = '21'; $siteid = '13'; $data = str_replace('=', '', base64_encode($campaignid.':'.$programid.':'.$siteid)); echo $data."\n"; ?>