Skip to content

Instantly share code, notes, and snippets.

@fomkin
Last active May 20, 2016 12:44
Show Gist options
  • Save fomkin/f8e30f05b8ca436e6ee7a9f62fbc6b3f to your computer and use it in GitHub Desktop.
Save fomkin/f8e30f05b8ca436e6ee7a9f62fbc6b3f to your computer and use it in GitHub Desktop.
<?
$ADDYBOT_TOKEN = 'Your token from AddyBot Cabinet';
// The data to send to the API
$postData = array(
'language' => 'english',
'userIdentifier' => 'telegram_user_id'
);
// Setup cURL
$ch = curl_init('https://api.addybot.com/'.$ADDYBOT_TOKEN.'/ad');
curl_setopt_array($ch, array(
CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json; charset=UTF-8'
),
CURLOPT_POSTFIELDS => json_encode($postData)
));
// Send the request
$response = curl_exec($ch);
// Check for errors
if($response === FALSE){
die(curl_error($ch));
}
// Decode the response
$responseData = json_decode($response, TRUE);
// Ad is there
echo $responseData;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment