Binom Documentation

К навигации

Click API

With Click API you can get all the data for a click from the tracker wihout waiting or using an additional redirect. For example you can send your traffic right to your landing page and filter it by IP, geo, device and other things you setup in the tracker's campaign.
Also Click API allows you to avoid an additional redirect beween landing page and offer.

Its functionality is based on PHP-file binom_click_api.php, which should be connected with your landing page:

  • binom_click_api.php
      $CampaignLink=''; $ApiKey='YYY'; $getClick=new getClick($CampaignLink, $ApiKey); class getClick{ function __construct($CampaignLink, $ApiKey){ if(strpos($CampaignLink, '?')!==false){ $this->ClickURL=$CampaignLink.'&lp_type=click_info&api_key='.$ApiKey; }else{ $this->ClickURL=$CampaignLink.'?lp_type=click_info&api_key='.$ApiKey; } if(isset($_GET)){ foreach($_GET AS $key=>$val){ $this->ClickURL=$this->ClickURL.'&'.$key.'='.$val; } } $this->DataClick=$this->getClickData($this->ClickURL); } function getLanding(){ if(isset($this->DataClick['landing']['type'])){ if($this->DataClick['landing']['id']==0 || $this->DataClick['landing']['name']=='DIRECT'){ echo 'Direct'; }else{ if($this->DataClick['landing']['type']==2){ $this->includeLanding(); }else{ echo $this->loadLanding(); } } } } function includeLanding(){ ob_start(); include($this->getLandingUrl()); return $this->replaceLandingLink(ob_get_clean()); } function loadLanding(){ return $this->replaceLandingLink(file_get_contents($this->getLandingUrl())); } function replaceLandingLink($html){ if(isset($this->DataClick['uclick'])){ $html=str_replace('?lp=1','?lp=1&uclick='.$this->DataClick['uclick'],$html); } return $html; } function getOfferUrl(){ $OfferUrl='Unknown'; if(isset($this->DataClick['offer']['url'])){ $OfferUrl=$this->DataClick['offer']['url']; } return $OfferUrl; } function getLandingUrl(){ $LandingUrl='Unknown'; if(isset($this->DataClick['landing']['url'])){ if($this->DataClick['landing']['id']=='0'){ $LandingUrl='Direct'; }else{ $LandingUrl=$this->DataClick['landing']['url']; } } return $LandingUrl; } function getClickData($ClickURL){ $ClickURL=$ClickURL.$this->getClickGet(); $ClickOptions=$this->getClickOptions(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $ClickURL); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, 0); if(!empty($ClickOptions)){ curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $ClickOptions); } $result = curl_exec( $ch ); curl_close( $ch ); if(!$result=json_decode($result,true)){ $result['status']='error'; $result['error']='Incorrect Campaign link'; } return $result; } function getClickGet(){ $gets=''; foreach($_GET AS $key=>$val){ $gets=$gets.'&'.$key.'='.$val; } return $gets; } function getClickOptions(){ $posts=array(); foreach($_POST AS $key=>$val){ $posts[]=$key.'='.$val; } $Headers=array(); $TrueHeaders=array( 'REMOTE_ADDR','HTTP_USER_AGENT','HTTP_COOKIE','HTTP_X_PURPOSE', 'HTTP_REFERER','HTTP_ACCEPT_LANGUAGE','HTTP_X_FORWARDED_FOR' ); foreach($_SERVER AS $key=>$val){ if(in_array($key,$TrueHeaders)){ $Headers[$key]=$val; } } if(!isset($Headers['HTTP_X_FORWARDED_FOR']) && isset($Headers['REMOTE_ADDR'])){ $Headers['HTTP_X_FORWARDED_FOR']=$Headers['REMOTE_ADDR']; } $posts[]='ClickDataHeaders='.json_encode($Headers); return implode('&',$posts); } } ?>

You should put your campaign link in $CampaignLink (with only key parameter) and your API-key in $ApiKey
You need to send traffic source tokens into the landing URL (with Click-API) to be taken into stats by the tracker.
Your landing should have .php extension since it works on PHP.


$getClick=new getClick($CampaignLink, $ApiKey);Send click to the tracker,
this is necessary option,
all other options won't work without it
$getClick->DataClick;Display all click data
$getClick->getLanding()Load the landing page
$getClick->getLandingUrl();Get the landing page URL
$getClick->getOfferUrl();Get the offer URL


If you want to use one LP with Click API with multiple campaigns - you should:
1) Remove the campaign key from $CampaignLink: '';
2) Pass the parameter key with your campaign key in the landing page URL.


Click API doesn't work with cookies so in order to work with LP Tokens, Events и Conversion Pixel you should add the uclick. parameter into the request. You can get this parameter with $getClick->DataClick;.