|
@@ -119,10 +119,10 @@ class InstagramService implements SmmPlatformInterface
|
|
|
|
|
|
// If single image
|
|
// If single image
|
|
if (count($imagePaths) === 1) {
|
|
if (count($imagePaths) === 1) {
|
|
- Log::info('单图发帖');
|
|
|
|
|
|
+ Log::info('Instagram单图发帖');
|
|
$imagePath = $imagePaths[0];
|
|
$imagePath = $imagePaths[0];
|
|
// Create media container for single image
|
|
// Create media container for single image
|
|
- Log::info('开始创建媒体容器');
|
|
|
|
|
|
+ Log::info('Instagram开始创建媒体容器');
|
|
$postData = [
|
|
$postData = [
|
|
'image_url' => $imagePath, // Assuming images are publicly accessible
|
|
'image_url' => $imagePath, // Assuming images are publicly accessible
|
|
'caption' => $message,
|
|
'caption' => $message,
|
|
@@ -137,7 +137,7 @@ class InstagramService implements SmmPlatformInterface
|
|
return ['status' => false, 'data' => '错误:无法创建媒体容器 - ' . json_encode($containerData)];
|
|
return ['status' => false, 'data' => '错误:无法创建媒体容器 - ' . json_encode($containerData)];
|
|
}
|
|
}
|
|
|
|
|
|
- Log::info('开始发布媒体容器');
|
|
|
|
|
|
+ Log::info('Instagram开始发布媒体容器');
|
|
// Publish the container
|
|
// Publish the container
|
|
$publishResponse = Http::timeout($this->timeout)->connectTimeout($this->connectTimeout)->post("https://graph.instagram.com/v21.0/{$igUserId}/media_publish", [
|
|
$publishResponse = Http::timeout($this->timeout)->connectTimeout($this->connectTimeout)->post("https://graph.instagram.com/v21.0/{$igUserId}/media_publish", [
|
|
'creation_id' => $containerData['id'],
|
|
'creation_id' => $containerData['id'],
|
|
@@ -160,7 +160,7 @@ class InstagramService implements SmmPlatformInterface
|
|
$requestContent = [];
|
|
$requestContent = [];
|
|
$responseContent = [];
|
|
$responseContent = [];
|
|
foreach ($imagePaths as $imagePath) {
|
|
foreach ($imagePaths as $imagePath) {
|
|
- Log::info('多图发帖');
|
|
|
|
|
|
+ Log::info('Instagram多图发帖');
|
|
$postData = [
|
|
$postData = [
|
|
'image_url' => asset($imagePath),
|
|
'image_url' => asset($imagePath),
|
|
'is_carousel_item' => true,
|
|
'is_carousel_item' => true,
|
|
@@ -170,7 +170,7 @@ class InstagramService implements SmmPlatformInterface
|
|
'url'=>"https://graph.instagram.com/v21.0/{$igUserId}/media",
|
|
'url'=>"https://graph.instagram.com/v21.0/{$igUserId}/media",
|
|
'postData' => $postData,
|
|
'postData' => $postData,
|
|
];
|
|
];
|
|
- Log::info('上传子媒体容器');
|
|
|
|
|
|
+ Log::info('Instagram上传子媒体容器');
|
|
$childResponse = Http::timeout($this->timeout)->connectTimeout($this->connectTimeout)->asForm()->post("https://graph.instagram.com/v21.0/{$igUserId}/media", $postData);
|
|
$childResponse = Http::timeout($this->timeout)->connectTimeout($this->connectTimeout)->asForm()->post("https://graph.instagram.com/v21.0/{$igUserId}/media", $postData);
|
|
|
|
|
|
$childData = $childResponse->json();
|
|
$childData = $childResponse->json();
|
|
@@ -234,7 +234,7 @@ class InstagramService implements SmmPlatformInterface
|
|
if (empty($videoPath)) {
|
|
if (empty($videoPath)) {
|
|
return ['status' => false, 'data' => '错误:未提供视频路径'];
|
|
return ['status' => false, 'data' => '错误:未提供视频路径'];
|
|
}
|
|
}
|
|
- Log::info("开始上传视频");
|
|
|
|
|
|
+ Log::info("Instagram 开始上传视频");
|
|
$igUserId = $this->configData['accountInfo']['account_id'];
|
|
$igUserId = $this->configData['accountInfo']['account_id'];
|
|
|
|
|
|
// Create media container for video
|
|
// Create media container for video
|
|
@@ -247,9 +247,9 @@ class InstagramService implements SmmPlatformInterface
|
|
$containerResponse = Http::timeout($this->timeout)->connectTimeout($this->connectTimeout)->asForm()->post("https://graph.instagram.com/v21.0/{$igUserId}/media", $postData);
|
|
$containerResponse = Http::timeout($this->timeout)->connectTimeout($this->connectTimeout)->asForm()->post("https://graph.instagram.com/v21.0/{$igUserId}/media", $postData);
|
|
$containerData = $containerResponse->json();
|
|
$containerData = $containerResponse->json();
|
|
if (!isset($containerData['id'])) {
|
|
if (!isset($containerData['id'])) {
|
|
- return ['status' => false, 'data' => '错误:无法创建视频容器 - ' . json_encode($containerData)];
|
|
|
|
|
|
+ return ['status' => false, 'data' => '错误:无法创建视频容器 - ' . $containerResponse->body()];
|
|
}
|
|
}
|
|
- Log::info("创建视频的媒体容器完成");
|
|
|
|
|
|
+ Log::info("Instagram 创建视频的媒体容器完成:".$containerResponse->body());
|
|
// Check container status (video processing may take time)
|
|
// Check container status (video processing may take time)
|
|
$status = 'IN_PROGRESS';
|
|
$status = 'IN_PROGRESS';
|
|
$maxAttempts = 10;
|
|
$maxAttempts = 10;
|
|
@@ -267,10 +267,10 @@ class InstagramService implements SmmPlatformInterface
|
|
$attempt++;
|
|
$attempt++;
|
|
|
|
|
|
if ($status === 'ERROR') {
|
|
if ($status === 'ERROR') {
|
|
- return ['status' => false, 'data' => '错误:视频处理失败'];
|
|
|
|
|
|
+ return ['status' => false, 'data' => '错误:视频处理失败'.$statusResponse->body()];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- Log::info("检查容器状态完成");
|
|
|
|
|
|
+ Log::info("Instagram 检查容器状态完成");
|
|
if ($status !== 'FINISHED') {
|
|
if ($status !== 'FINISHED') {
|
|
return ['status' => false, 'data' => '错误:视频处理超时'];
|
|
return ['status' => false, 'data' => '错误:视频处理超时'];
|
|
}
|
|
}
|
|
@@ -280,7 +280,7 @@ class InstagramService implements SmmPlatformInterface
|
|
'access_token' => $accessToken,
|
|
'access_token' => $accessToken,
|
|
];
|
|
];
|
|
$publishResponse = Http::timeout($this->timeout)->connectTimeout($this->connectTimeout)->post("https://graph.instagram.com/v21.0/{$igUserId}/media_publish",$postData);
|
|
$publishResponse = Http::timeout($this->timeout)->connectTimeout($this->connectTimeout)->post("https://graph.instagram.com/v21.0/{$igUserId}/media_publish",$postData);
|
|
- Log::info("发布视频完成");
|
|
|
|
|
|
+ Log::info("Instagram 发布视频完成".$publishResponse->body());
|
|
$publishData = $publishResponse->json();
|
|
$publishData = $publishResponse->json();
|
|
if (!isset($publishData['id'])) {
|
|
if (!isset($publishData['id'])) {
|
|
return ['status' => false, 'data' => '错误:无法发布视频 - ' . json_encode($publishData)];
|
|
return ['status' => false, 'data' => '错误:无法发布视频 - ' . json_encode($publishData)];
|