1. Home
  2. Docs
  3. API Integration
  4. Offer Wall API
  5. Call Examples

Call Examples

PHP

<?php
// Initialize cURL and make the request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.adgem.com/v1/wall/json?appid=ADGEM_APP_ID&playerid=PLAYER_ID');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);

// Decode the response into a PHP associative array
$response = json_decode($response, true);

// Make sure that there wasn't a problem decoding the repsonse
if(json_last_error()!==JSON_ERROR_NONE){
	throw new RuntimeException(
		'API response not well-formed (json error code: '.json_last_error().')'
	);
}

// Print out the response details or, any error messages
if(isset($response['status']) && $response['status']==="success"){
	echo 'API call successful';
	echo PHP_EOL;
	echo 'Response Data: <pre>'.print_r($response['data'], true).'';
	echo PHP_EOL;
}else if(isset($response['status']) && $response['status']==="error"){
	echo 'API call error';
	echo PHP_EOL;
	echo 'Errors: <pre>'.print_r($response['data'], true).'';
	echo PHP_EOL;
}else{
	echo 'API call failed';
	echo PHP_EOL;
	echo 'Errors: <pre>'.print_r($response['data'], true).'';
	echo PHP_EOL;
}
?>

Python

# importing the requests library 
import requests 
  
# defining the api-endpoint  
API_ENDPOINT = "https://api.adgem.com/v1/wall/json"
  
# your Adgem App ID 
ADGEM_APP_ID = "xxxxx"
  
# data to be sent to api 
data = {'appid':ADGEM_APP_ID, 
        'playerid':'YOUR_PLAYER_ID'} 
  
# sending post request and saving response as response object 
r = requests.post(url = API_ENDPOINT, data = data) 
  
# extracting response data 
offerwall_data = r.data 
print(offerwall_data) 

Ruby

require 'net/http'
require 'json'

url = 'https://api.adgem.com/v1/wall/json?appid=ADGEM_APP_ID&playerid=PLAYER_ID'
uri = URI(url)
response = Net::HTTP.get(uri)
JSON.parse(response)
Tags , , , ,
Was this article helpful to you? Yes 6 No