Last active
May 20, 2016 12:44
-
-
Save fomkin/f8e30f05b8ca436e6ee7a9f62fbc6b3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$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