private static function getDeviceJson($device) { $deviceArray = array(); $deviceArray['ip'] = $device->carrierIP; $deviceArray['ua'] = htmlspecialchars($device->userAgent, ENT_QUOTES); //anddroid identifiers $gpid = $device->gpId; if (StubValidator::isStringValid($gpid)) { $deviceArray['gpid'] = $gpid; } //aid here must be a SHA-1 hashed value of the original ANDROID_ID, or otherwise should be //passed as md5 value.. // if you don't know this, do not pass this identifier, but rather pass google advertising identifier. $aid = $device->androidId; if (StubValidator::isStringValid($aid)) { $deviceArray['o1'] = $aid; } //iOS identifiers $ida = $device->idfa; if (StubValidator::isStringValid($ida)) { $deviceArray['ida'] = $ida; } $adt = $device->adTrackingDisabled; if ($adt == true) { $deviceArray['adt'] = 1; } else { $deviceArray['adt'] = 0; } //geo object $geo = $device->geo; if ($geo != null && $geo->isValid() == true) { $geoArray = array(); $geoArray['lat'] = $geo->lat; $geoArray['lon'] = $geo->lon; $geoArray['accu'] = $geo->accuracy; $deviceArray['geo'] = $geoArray; } return $deviceArray; }
/** * Use this method to check if this Object has all the required parameters * present, to be used to construct a JSON request. The required parameters * would be specific to an ad-format. * * @return If the mandatory params are present, then true, otherwise false. */ public function isValid() { if (StubValidator::isStringValid($this->carrierIP) == false) { return false; } if (StubValidator::isStringValid($this->userAgent) == false) { return false; } //put checks for device id later on.. return true; }