account_ids); $accounts = SmmUserAccount::getAccountsByIds($accountIds); foreach ($accounts as $account) { //生成post_logs表数据 $data = [ 'post_id' => $post->id, 'account_id' => $account->id, 'account_name' => $account->name, 'status' => 0, 'remark' => '', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now(), 'dist_id' => $account->dist_id, 'media_name' => $account->getParent->name, 'response_ids'=> '', 'send_time' => $post->send_time, ]; SmmPostLog::createLog($data); } $post->status = 1; $post->save(); } //dd('middle'); //发送社媒帖子开始 $sendLog = SmmPostLog::getSendLog(); foreach ($sendLog as $log) { //获取帖子内容 $post = SmmPost::getPostById($log->post_id); $message = $post->message; $imageVideoUrl = $post->image_video_url; // $imageVideoUrl = storage_path($imageVideoUrl); $mediaName = $log->media_name; $postType = $post->post_type; $accountInfo = SmmUserAccount::getAccountById($log->account_id); $accessToken = $accountInfo->access_token; //发送帖子 $configData = ['accountInfo' => $accountInfo->toArray()]; $ssmService = new SmmService($mediaName,$configData); if ($postType == 0) { //图片帖子 $imageVideoUrl = explode(',', $imageVideoUrl); foreach ($imageVideoUrl as $key => $url) { $imageVideoUrl[$key] = CommonHelper::ossUrl($url); } $response = $ssmService->postImage($message, $imageVideoUrl,$accessToken); } else { $imageVideoUrl = CommonHelper::ossUrl($imageVideoUrl); // $response = $ssmService->postVideo($message, $imageVideoUrl,$accessToken); $response = $ssmService->postVideo([ 'title' => 'Test Video', 'description' => 'This is a test video111', 'categoryId' => '22', // People & Blogs 'privacyStatus' => 'private' ], '/mnt/hgfs/wwwroot/mtb_dcatadmin_plus/1.mp4', $accessToken); } dd($response); //更新post_logs表 if ($response['status'] == true) { $log->status = 1; $log->response_ids = json_encode($response['data']['responseIds']); $log->request_content = json_encode($response['data']['requestContent']); $log->response_content = json_encode($response['data']['responseContent']); $log->updated_at = Carbon::now(); $log->send_time = Carbon::now(); $log->save(); } else { $log->status = 2; $log->remark = $response['data']; $log->updated_at = Carbon::now(); $log->send_time = Carbon::now(); $log->save(); } } dd('发送社媒帖子完成'); } }