Created
April 5, 2016 14:15
-
-
Save joshdutcher/6c5f527373f6324334e7d997a371fbb2 to your computer and use it in GitHub Desktop.
Rubicon reconciliation API call
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
// of course there is actually more to the code than this but here's the relevant part | |
function getRubiconRecon($date,$freq) { | |
$key = "************************************"; | |
$secret = "************************************"; | |
$url = "https://api.rubiconproject.com"; | |
$acct = "*****"; | |
$request = "/sellers/api/reports/v1/$acct?columns=Site_Name,Site_ID,Performance_NetworkImps,Performance_FillRate,Traffic_Impressions,Performance_NetworkRevenue,Performance_ECPM,SiteData_KeywordMapped&source=standard&start=$date&end=$date"; | |
$options = array('timeout' => '30', 'auth' => new Requests_Auth_Basic(array($key, $secret)), 'filename' => 'rubicon_body.txt'); | |
$headers = array('Accept' => 'application/json', 'Content-Type' => 'application/json'); | |
try { | |
$res = Requests::get($url.$request, $headers, $options); | |
} catch (Requests_Exception $e) { | |
$log->log($logfile, 'ERROR -- Caught exception in Rubicon API request: ' . $e->getMessage()); | |
// the log message alternates between the following | |
// cURL error 18: transfer closed with 6981 bytes remaining to read | |
// cURL error 28: Operation timed out after 29641 milliseconds with 1120 out of 8101 bytes received | |
// however if I check rubicon_body.txt, there is valid JSON there returned from the API. | |
// I would like to be able to access that JSON from a variable without having to read a file on disk. | |
continue; | |
} | |
// do some stuff here with the data received from the API | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment