XcJob.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <?php
  2. namespace app\extra\tools;
  3. use yzh52521\EasyHttp\Http;
  4. class XcJob
  5. {
  6. /**
  7. * 默认header
  8. * @var string[]
  9. */
  10. protected array $header = [
  11. "content-type" => "application/json"
  12. ];
  13. public function token(): static
  14. {
  15. $this->header = [
  16. "cookie" => $this->getCookie()
  17. ];
  18. return $this;
  19. }
  20. /**
  21. * 获取达人详情信息
  22. * @param string $uid
  23. * @return array
  24. */
  25. public function getStarDetail(string $uid = ""): array
  26. {
  27. $param = [
  28. "o_author_id" => $uid,
  29. "platform_source" => 1,
  30. "platform_channel" => 1,
  31. "recommend" => true,
  32. "need_sec_uid" => true,
  33. "need_linkage_info" => true
  34. ];
  35. $resp = Http::withHeaders($this->header)->asJson()->get("https://www.xingtu.cn/gw/api/author/get_author_base_info",$param)->array();
  36. if (empty($resp['sec_uid'])) return [0,'获取数据失败'];
  37. return [1,$resp];
  38. }
  39. /**
  40. * 获取达人信息
  41. * {"scene_param":{"platform_source":1,"search_scene":1,"display_scene":1,"marketing_target":1,"task_category":1,"first_industry_id":0,"task_status":3},"search_param":{"keyword":"11_0306","seach_type":2,"is_new_nickname_query":true},"sort_param":{"sort_type":2,"sort_field":{"field_name":"score"}},"page_param":{"page":1,"limit":20},"attribute_filter":[{"field":{"field_name":"price_by_video_type__ge","rel_id":"2"},"field_value":"0"}]}
  42. * @param string $uid
  43. * @return array
  44. */
  45. public function getStarData(string $uid = ""): array
  46. {
  47. $param = [
  48. "scene_param" => [
  49. "platform_source" => 1,
  50. "search_scene" => 1,
  51. "display_scene" => 1,
  52. "marketing_target" => 1,
  53. "task_category" => 1,
  54. "first_industry_id" => 0,
  55. "task_status" => 3
  56. ],
  57. "search_param" => [
  58. "keyword" => $uid,
  59. "seach_type" => 2,
  60. "is_new_nickname_query" => true
  61. ],
  62. "sort_param" => [
  63. "sort_type" => 2,
  64. "sort_field" => [
  65. "field_name" => "score"
  66. ]
  67. ],
  68. "page_param" => [
  69. "page" => 1,
  70. "limit" => 20
  71. ]
  72. ];
  73. $resp = Http::withHeaders($this->header)->asJson()->post("https://www.xingtu.cn/gw/api/gsearch/search_for_author_square",$param)->array();
  74. if ($resp['base_resp']['status_code'] <> 0) return [0,'获取数据失败'];
  75. return [1,['total' => $resp['pagination']['total_count'],'has_more' => $resp['pagination']['has_more'],'list' => $resp['authors']]];
  76. }
  77. /**
  78. * 获取星川任务列表
  79. * @param int $page
  80. * @param int $size
  81. * @return array
  82. */
  83. public function getTaskList(int $page = 1,int $size = 10): array
  84. {
  85. // {"query":{"task_category_list":[137],"order_status":[],"qc_metrics_time_range_param":{"start_time":"1767628800000","end_time":"1783353599000"}},"page":1,"limit":10}
  86. $param = [
  87. "query" => [
  88. "task_category_list" => [137],
  89. "order_status" => [],
  90. "qc_metrics_time_range_param" => [
  91. "start_time" => strtotime(date("Y-m-d 00:00:00",strtotime("-360 day"))) * 1000,
  92. "end_time" => strtotime(date("Y-m-d 23:59:59")) * 1000,
  93. ]
  94. ],
  95. "page" => $page,
  96. "limit" => $size
  97. ];
  98. $resp = Http::withHeaders($this->header)->asJson()->post("https://www.xingtu.cn/gw/api/task/provider_get_task_order_list",$param)->array();
  99. if ($resp['base_resp']['status_code'] <> 0) return [0,'获取数据失败'];
  100. return [1,['total' => $resp['pagination']['total_count'],'has_more' => $resp['pagination']['has_more'],'page' => $resp['pagination']['page'],'list' => $resp['provider_task_order_list']]];
  101. }
  102. /**
  103. * 投稿达人
  104. * @param string $jobId
  105. * @param int $page
  106. * @param int $size
  107. * @return array
  108. */
  109. public function getTaskAuthor(string $jobId = "",int $page = 1,int $size = 10): array
  110. {
  111. // {"task_id":"7650432488166899755","qc_metrics_time_range_param":{"start_time":"1767628800000","end_time":"1783353599000"},"page":2,"limit":10,"scene":1}
  112. $param = [
  113. "task_id" => $jobId,
  114. "qc_metrics_time_range_param" => [
  115. "start_time" => strtotime(date("Y-m-d 00:00:00",strtotime("-180 day"))) * 1000,
  116. "end_time" => strtotime(date("Y-m-d 23:59:59")) * 1000,
  117. ],
  118. "page" => $page,
  119. "limit" => $size,
  120. "scene" => 1
  121. ];
  122. $resp = Http::withHeaders($this->header)->post("https://www.xingtu.cn/gw/api/task/provider_get_task_author_performance_list",$param)->array();
  123. if ($resp['base_resp']['status_code'] <> 0) return [0,'获取数据失败'];
  124. if ($resp['pagination']['total_count'] == 0) return [0,'没有数据'];
  125. return [1,['total' => $resp['pagination']['total_count'],'has_more' => $resp['pagination']['has_more'],'page' => $resp['pagination']['page'],'list' => $resp['author_list']]];
  126. }
  127. /**
  128. * 获取达人投稿视频消耗数据
  129. * https://www.xingtu.cn/gw/api/task/provider_get_star_task_item_list
  130. * POST
  131. * {"page":1,"limit":10,"query":{"provider_confirmed":false,"task_search_key":"7628487095040311348","qc_metrics_time_range_param":{"start_time":"1762963200000","end_time":"1778687999000"}}}
  132. * @param string $jobId
  133. * @param int $page
  134. * @param int $size
  135. * @return array
  136. */
  137. public function getAuthorVideo(string $jobId = "",int $page = 1,int $size = 10): array
  138. {
  139. $param = [
  140. "page" => $page,
  141. "limit" => $size,
  142. "query" => [
  143. "provider_confirmed" => false,
  144. "task_search_key" => $jobId,
  145. "qc_metrics_time_range_param" => [
  146. "start_time" => strtotime(date("Y-m-d 00:00:00",strtotime("-180 day"))) * 1000,
  147. "end_time" => strtotime(date("Y-m-d 23:59:59")) * 1000,
  148. ]
  149. ]
  150. ];
  151. $resp = Http::withHeaders($this->header)->asJson()->post("https://www.xingtu.cn/gw/api/task/provider_get_star_task_item_list",$param)->array();
  152. if ($resp['base_resp']['status_code'] <> 0) return [0,'获取数据失败'];
  153. return [1,['total' => $resp['pagination']['total_count'],'has_more' => $resp['pagination']['has_more'],'page' => $resp['pagination']['page'],'list' => $resp['item_list']]];
  154. }
  155. /**
  156. * 获取单个任务中指定达人的投稿视频
  157. * @param string $jobId
  158. * @param int $page
  159. * @param int $size
  160. * @return array
  161. */
  162. public function getAuthorVide2Task(string $jobId = "",string $starId = "",int $page = 1,int $size = 10): array
  163. {
  164. $param = [
  165. "page" => $page,
  166. "limit" => $size,
  167. "query" => [
  168. "provider_confirmed" => false,
  169. "task_search_key" => $jobId,
  170. "author_search_key" => $starId,
  171. "qc_metrics_time_range_param" => [
  172. "start_time" => strtotime(date("Y-m-d 00:00:00",strtotime("-180 day"))) * 1000,
  173. "end_time" => strtotime(date("Y-m-d 23:59:59")) * 1000,
  174. ]
  175. ]
  176. ];
  177. $resp = Http::withHeaders($this->header)->asJson()->post("https://www.xingtu.cn/gw/api/task/provider_get_star_task_item_list",$param)->array();
  178. if ($resp['base_resp']['status_code'] <> 0) return [0,'获取数据失败'];
  179. return [1,['total' => $resp['pagination']['total_count'],'has_more' => $resp['pagination']['has_more'],'page' => $resp['pagination']['page'],'list' => $resp['item_list']]];
  180. }
  181. /**
  182. * 获取视频播放链接
  183. * @param string $videoId
  184. * @return array
  185. */
  186. public function getVideoDetail(string $videoId = ""): array
  187. {
  188. $param = [
  189. "video_id" => $videoId
  190. ];
  191. $resp = Http::withHeaders($this->header)->get("https://www.xingtu.cn/gw/api/ggeneric/get_video_info",$param)->array();
  192. if ($resp['base_resp']['status_code'] <> 0) return [0,'获取数据失败'];
  193. return [1,['cover' => $resp['cover'],'duration' => $resp['duration'],'play_url' => $resp['play_url'],'width' => $resp['width'],'height' => $resp['width']]];
  194. }
  195. /**
  196. * 生成邀约达人参与任务二维码
  197. * @param string $jobId
  198. * @return array
  199. */
  200. public function createJobQrcode(string $jobId = ""): array
  201. {
  202. $param = [
  203. "template_id" => "7550880075256709158",
  204. "placeholder_params" => [
  205. "challenge_id" => $jobId,
  206. "provider_id" => "1829709687645195",
  207. "utm_medium" => "xingtu_provider_star_qc_unite_invite"
  208. ],
  209. "expired_time" => strtotime("+1 year"), // 有效期1年
  210. "event_id" => $jobId,
  211. "share_type" => 4
  212. ];
  213. $resp = Http::withHeaders($this->header)->asJson()->post("https://www.xingtu.cn/gw/api/fe_common_service/share/info",$param)->array();
  214. if ($resp['base_resp']['status_code'] <> 0) return [0,'生成失败'];
  215. return [1,"https://www.xingtu.cn/share/{$resp['share_id']}?hide_nav_bar=1&hide_status_bar=1&should_full_screen=1&utm_source=share_4&session_track_id={$resp['share_id']}"];
  216. }
  217. /**
  218. * 星川任务详情 - 项目
  219. * @param string $jobId
  220. * @return array
  221. */
  222. public function getJobDetail(string $jobId = ""): array
  223. {
  224. return Http::withHeaders($this->header)->get("https://www.xingtu.cn/gw/api/task/provider_get_project_detail",['project_id' => $jobId])->array();
  225. }
  226. /**
  227. * 星川任务详情 - 任务
  228. * @param string $jobId
  229. * @return array
  230. */
  231. public function getTaskDetail(string $jobId = ""): array
  232. {
  233. return Http::withHeaders($this->header)->get("https://www.xingtu.cn/gw/api/task/provider_get_task_detail",['task_id' => $jobId])->array();
  234. }
  235. protected function getCookie(): string
  236. {
  237. return "csrftoken=DiDhfVo0pz9HnEsJ3zGKA39ixm9AxA8t; tt_webid=7637854168573183526; is_staff_user=false; has_biz_token=false; s_v_web_id=verify_mqhwxxgj_rimh5qRs_m3VS_4oAv_8yXX_EMfuKVBYkpVW; passport_auth_status=39cd9f76ea3c8ac5c9beab7dfee4825f%2C56147e39ce55d737468b0c00fe003bc2; passport_auth_status_ss=39cd9f76ea3c8ac5c9beab7dfee4825f%2C56147e39ce55d737468b0c00fe003bc2; uid_tt=32a10b0de605d5e5e09080d5531eb77e; uid_tt_ss=32a10b0de605d5e5e09080d5531eb77e; sid_tt=528106ce020f1db0e4ca4ff7895135ef; sessionid=528106ce020f1db0e4ca4ff7895135ef; sessionid_ss=528106ce020f1db0e4ca4ff7895135ef; Hm_lvt_5d77c979053345c4bd8db63329f818ec=1781690725,1782806402; HMACCOUNT=7B24288D273CC431; csrf_session_id=7b04abc1fd6e463b4e7e191681f733da; Hm_lpvt_5d77c979053345c4bd8db63329f818ec=1783665817; passport_csrf_token=769a68a189b6cde4cf43efe68412d7cc; passport_csrf_token_default=769a68a189b6cde4cf43efe68412d7cc; sid_guard=528106ce020f1db0e4ca4ff7895135ef%7C1783665835%7C5184000%7CTue%2C+08-Sep-2026+06%3A43%3A55+GMT; session_tlb_tag=sttt%7C9%7CUoEGzgIPHbDkyk_3iVE17__________0dbcF7DEwEMKososyJJhu2QhkA2vxJQ_iQSg2uymqiXU%3D; sid_ucp_v1=1.0.0-KDhiYzQ2OGM1NTc1OWUzN2VhYmIyOWVkYTg4MmE0MTNkYTU0ZWI4MDYKFwiUv5Cvv8yyBxCrqcLSBhimDDgCQPEHGgJsZiIgNTI4MTA2Y2UwMjBmMWRiMGU0Y2E0ZmY3ODk1MTM1ZWY; ssid_ucp_v1=1.0.0-KDhiYzQ2OGM1NTc1OWUzN2VhYmIyOWVkYTg4MmE0MTNkYTU0ZWI4MDYKFwiUv5Cvv8yyBxCrqcLSBhimDDgCQPEHGgJsZiIgNTI4MTA2Y2UwMjBmMWRiMGU0Y2E0ZmY3ODk1MTM1ZWY; star_sessionid=31ef398c5df8ba8f37d006946bab5133";
  238. }
  239. }