[ 'api_key' => $apiKey, 'customer_id' => $customerId, 'app_id' => $appId, 'video_id' => $videoId, 'drama_sort' => $dramaSort, 'remark' => $remark ], 'response' => $responseData ], 'jiashuApi'); sleep(1); return $responseData; } /* * 获取剧列表 * */ public static function getContentList( $apiKey, $customerId, $page = null, $appId ) { $requestUri = config('jiashu.get_content_list'); $paramsArr['app_id'] = $appId; $paramsArr['customer_id'] = $customerId; if(!is_null($page)) $paramsArr['page'] = $page; $paramsArr['timestamp'] = time(); $params = self::createSign($apiKey, $paramsArr); $requestUri .= http_build_query($params); # 获取响应数据 $response = HttpService::httpGet($requestUri); $responseData = json_decode($response, true); Log::logInfo('获取短剧列表', [ 'params' => [ 'api_key' => $apiKey, 'customer_id' => $customerId, 'app_id' => $appId, 'page' => $page, ], 'response' => $responseData ], 'jiashuApi'); return $responseData; } /* * 获取剧集列表 * */ public static function getSectionList($apiKey, $customerId, $appId, $videoId) { $requestUri = config('jiashu.get_section_list'); $paramsArr['app_id'] = $appId; $paramsArr['customer_id'] = $customerId; $paramsArr['timestamp'] = time(); $paramsArr['video_id'] = $videoId; $params = self::createSign($apiKey, $paramsArr); $requestUri .= http_build_query($params); # 获取响应数据 $response = HttpService::httpGet($requestUri); $responseData = json_decode($response, true); Log::logInfo('获取剧集列表', [ 'params' => [ 'api_key' => $apiKey, 'customer_id' => $customerId, 'app_id' => $appId, 'video_id' => $videoId, ], 'response' => $responseData ], 'jiashuApi'); return $responseData; } /* * 获取应用列表 * */ public static function getAppList($apiKey, $customerId) { $requestUri = config('jiashu.get_app_list'); $paramsArr['customer_id'] = $customerId; $paramsArr['timestamp'] = time(); $params = self::createSign($apiKey, $paramsArr); # 获取响应数据 $response = HttpService::httpPost($requestUri, $params); $responseData = json_decode($response, true); Log::logInfo('获取产品列表', [ 'params' => [ 'api_key' => $apiKey, 'customer_id' => $customerId, ], 'response' => $responseData ], 'jiashuApi'); return $responseData; } public static function createSign($apiKey, $paramsArr) { $params = []; foreach($paramsArr as $k=> $v) { $params[] = $k.'='.$v; } sort($params); $string = implode('&', $params); $sign = md5($apiKey.$string); $paramsArr['sign'] = $sign; return $paramsArr; } # 获取推广链接 public static function getArticle($apiKey, $customerId, $appId, $article, $retry = 0) { $requestUri = config('jiashu.get_article'); $paramsArr['app_id'] = $appId; $paramsArr['article'] = $article; $paramsArr['customer_id'] = $customerId; $paramsArr['timestamp'] = time(); $params = self::createSign($apiKey, $paramsArr); $requestUri .= http_build_query($params); # 获取响应数据 $response = HttpService::httpGet($requestUri); $responseData = json_decode($response, true); Log::logInfo('获取推广链接', [ 'params' => [ 'api_key' => $apiKey, 'customer_id' => $customerId, 'app_id' => $appId, 'article' => $article, 'retry' => $retry ], 'response' => $responseData ], 'jiashuApi'); $code = $responseData['code'] ?? 1; if($code) { $retry++; if($retry < 2) { sleep(1); return self::getArticle($apiKey, $customerId, $appId, $article, $retry); } } return $responseData; } public static function getArticleList($apiKey, $customerId, $appId, $statTime, $endTime, $retry = 0) { $requestUri = config('jiashu.get_article_data'); $paramsArr['app_id'] = $appId; $paramsArr['customer_id'] = $customerId; $paramsArr['end_time'] = $endTime; $paramsArr['start_time'] = $statTime; $paramsArr['timestamp'] = time(); $params = self::createSign($apiKey, $paramsArr); $requestUri .= http_build_query($params); # 获取响应数据 $response = HttpService::httpGet($requestUri); $responseData = json_decode($response, true); Log::logInfo('获取公众号推文数据', [ 'params' => [ 'api_key' => $apiKey, 'customer_id' => $customerId, 'app_id' => $appId, 'start_time' => $statTime, 'end_time' => $endTime, 'retry' => $retry ], 'response' => $responseData ], 'jiashuApi'); $code = $responseData['code'] ?? 1; if($code) { $retry++; if($retry < 2) { sleep(1); return self::getArticleList($apiKey, $customerId, $appId, $statTime, $endTime, $retry); } } return $responseData; } }