Skip to content

Instantly share code, notes, and snippets.

@snarky
Last active February 2, 2023 13:20
Show Gist options
  • Select an option

  • Save snarky/268d4d6794b10fceae2d7b09e78854b1 to your computer and use it in GitHub Desktop.

Select an option

Save snarky/268d4d6794b10fceae2d7b09e78854b1 to your computer and use it in GitHub Desktop.
{
"uid": "<UID>",
"code": "TOTO",
"target": "https://google.Com"
}
{
"uid": "<UID>",
"keyword": "TOTO",
"target": "https://google.com",
"mutlitargets": [
{
"conditions": {"COUNTRY": ["en", "us", "au"]},
"target": "https://google.com/en"
},
{
"conditions": {"COUNTRY": ["be", "suisse"], "LANGUAGE": ["allemand"]},
"target": "https://google.com/be-wa"
}
{
"conditions": {"COUNTRY": ["be"]},
"target": "https://google.com/be-fr"
}
{
"conditions": {"COUNTRY": ["EN"]},
"target": "https://google.com/ca"
}
{
"conditions": {"COUNTRY": "US"},
"target": "https://google.com/us"
}
]
}
<?php
$data = request("/{keywork}"); //=> json
$target = $data["target"];
if (!isset($data['conditions']) ||empty($data['conditions'])) {
return $target;
}
foreach ($data['conditions'] as $condition) {
if ($condtion... === true)
{
return $condition["target"];
}
}
return $target;
/{KEYWORD} => {TARGET}
=> QRCODE /{KEYWORD} => (REDIRECToR) => {TARGET}
=> QRCODE /{KEYWORD}?utm_source=qrcode => (REDIRECTOR) => {TARGET}?utm_source=qrcode
/{KEYWORD}?toto=toto => {TARGET}?toto=toto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment