index3.php - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of index3.php.php
- <?php
- // Initialize cURL and make the request
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, 'https://affiliateads.api.hasoffers.com/Apiv3/json?NetworkToken=NETk68QSu1uuJ3zxpKsej0oDAODYB5&Target=Report&Method=getModSummaryLogs&fields[]=ModSummaryLog.country_code&fields[]=ModSummaryLog.message&fields[]=Offer.name&fields[]=ModSummaryLog.type&filters[ModSummaryLog.type][conditional]=EQUAL_TO&filters[ModSummaryLog.type][values]=error&sort[ModSummaryLog.date]=desc');
- 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['response']['status']) && $response['response']['status']===1){
- echo 'API call successful';
- echo PHP_EOL;
- echo 'Response Data: <pre>'.print_r($response['response']['data'], true).'';
- echo PHP_EOL;
- }else{
- echo 'API call failed'.(isset($response['response']['errorMessage'])?' ('.$response['response']['errorMessage'].')':'').'';
- echo PHP_EOL;
- echo 'Errors: <pre>'.print_r($response['response']['errors'], true).'';
- echo PHP_EOL;
- }
- ?>
File Description
- index3.php
- PHP Code
- 27 Jan-2020
- 1.38 Kb
You can Share it:
Latest PHP Pastes