123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- require_once(BASE_CORE_PATH . '/framework/function/http.php');
- class sapi
- {
- private $url = 'https://sapi.ads.oppomobile.com/v1/clue/sendData';
- private $ownerId = '1000178033';
- private $API_ID = 'cbbf0a225cd44cba81b9b6e093ded0a2';
- private $APIKEY = '0d10124566ff41c393c0c418a3ae147a';
- private function create_token()
- {
- $time = time();
- $sign = sha1($this->API_ID .$this->APIKEY . $time);
- return base64_encode($this->ownerId. ','. $this->API_ID. ',' .$time. ',' . $sign);
- }
- public function send($body)
- {
- $params['pageId'] = $body['pageId'];
- $params['ownerId'] = $this->ownerId;
- $params['ip'] = $_SERVER['REMOTE_ADDR'];
- $params['tid'] = $body['tid'];
- $params['lbid'] = $body['lbid'];
- $params['transformType'] = 101;
- $token = $this->create_token();
- $header = [
- 'Content-Type: application/json',
- "Authorization:Bearer {$token}"
- ];
- $params = json_encode($params);
- Log::record("sapi send json data {$params}", Log::ERR);
- $resp = http_post_data($this->url, $params, $header, $net_errno);
- if (empty($resp)) {
- Log::record("sapi send neterr {$net_errno}", Log::ERR);
- return false;
- } else {
- Log::record($resp, Log::DEBUG);
- $resp = json_decode($resp, true);
- if ($resp['code'] === 0) {
- return true;
- } else {
- Log::record("sapi send err {$resp['msg']}", Log::ERR);
- return false;
- }
- }
- }
- }
|