You must sign in to vote
1. Open file /app/controllers/InstagramController.php.
2. And after that code:
$Post->set("status", "published") ..... ->update();
2. Insert the new one:
// Check is post published or deleted $is_post_published = false; $media_check = 0; $media_check_count = 0; $post_id = $resp->getMedia()->getId(); do { try { $media_resp = $Instagram->media->getInfo($post_id); $media_check = 1; $is_post_published = true; } catch (\InstagramAPI\Exception\NetworkException $e) { // Couldn't connect to Instagram account because of network or connection error // Do nothing, just try again if ($media_check_count > 5) { $media_check = 1; } else { sleep(7); } } catch (\InstagramAPI\Exception\EmptyResponseException $e) { // Instagram send us empty response // Do nothing, just try again if ($media_check_count > 5) { $media_check = 1; } else { sleep(7); } } catch (\InstagramAPI\Exception\InstagramException $e) { $msg = __("Something went wrong! Post automatically deleted by Instagram.") . __("Description:") . " " . $e->getMessage(); $Post->set("data.post_deleted_details", $msg) ->set("status", "failed") ->update(); throw new Exception($msg); } catch (\Exception $e) { $msg = __("Something went wrong! Post automatically deleted by Instagram.") . __("Description:") . " " . $e->getMessage(); $Post->set("data.post_deleted_details", $msg) ->set("status", "failed") ->update(); throw new Exception($msg); } $media_check_count += 1; } while (!$media_check); // If post caption is empty, we will try to add this caption again if ($media_check && !empty($caption) && isset($media_resp) && in_array($type, ["timeline", "album"])) { $get_caption = $media_resp->getItems()[0]->getCaption(); if (empty($get_caption)) { set_time_limit(300); $caption_check = 0; $caption_check_count = 0; $caption_relogin = 0; $caption_relogin_count = 0; $is_connected_fail = false; do { if ($caption_relogin_count >= 7) { $is_connected_fail = true; } $caption_relogin_count += 1; // Login to Instagram again try { $Account->set("last_login", date("Y-m-d H:i:s", time() - 30*60)) ->save(); if ($is_mobile_proxy) { $Instagram = self::login($Account, 1); } else { $Instagram = self::login($Account); } $caption_relogin = 1; } catch (\InstagramAPI\Exception\NetworkException $e) { if ($is_connected_fail) { $caption_relogin = 1; } else { sleep(7); } } catch (\InstagramAPI\Exception\EmptyResponseException $e) { if ($is_connected_fail) { $caption_relogin = 1; } else { sleep(7); } } catch (\InstagramAPI\Exception\InstagramException $e) { $msg = $e->getMessage(); $Post->set("data.caption_relogin.is_ok", false) ->set("data.caption_relogin.msg", $e->getMessage()) ->update(); $caption_relogin = 1; } catch (\Exception $e) { $msg = $e->getMessage(); $Post->set("data.caption_relogin.is_ok", false) ->set("data.caption_relogin.msg", $e->getMessage()) ->update(); $caption_relogin = 1; } } while (!$caption_relogin); if (!$is_connected_fail) { $is_connected_fail = false; do { if ($caption_check_count >= 7) { $is_connected_fail = true; } $caption_check_count += 1; try { $caption_resp = $Instagram->media->edit($post_id, $caption); $caption_check = 1; $Post->set("data.caption_check.is_set", true) ->update(); } catch (\InstagramAPI\Exception\NetworkException $e) { if ($is_connected_fail) { $caption_check = 1; $Post->set("data.caption_check.is_set", false) ->set("data.caption_check.msg", $e->getMessage()) ->save(); } else { sleep(7); } } catch (\InstagramAPI\Exception\EmptyResponseException $e) { if ($is_connected_fail) { $caption_check = 1; $Post->set("data.caption_check.is_set", false) ->set("data.caption_check.msg", $e->getMessage()) ->save(); } else { sleep(7); } } catch (\InstagramAPI\Exception\InstagramException $e) { $msg = $e->getMessage(); $Post->set("data.caption_check.is_set", false) ->set("data.caption_check.msg", $e->getMessage()) ->update(); $caption_check = 1; } catch (\Exception $e) { $msg = $e->getMessage(); $Post->set("data.caption_check.is_set", false) ->set("data.caption_check.msg", $e->getMessage()) ->update(); $caption_check = 1; } } while (!$caption_check); } } }