Closed sup3rgiu closed 6 years ago
Well, if it works without the ...new Instagram(...);
line, then the issue is probably with that library, not the bot itself.
Strange that there is no error being logged.
Using getUpdates
method, when you send /command
to your bot, everything works fine?
What version of the bot are you using?
I'm using version 0.53.0.
I thought too that the problem could be with the Instagram library, but when I use getUpdates and send /command everything works fine.
Also, if I set webhook and call the command each X hours with cron.php and a cron job, it works too.
So the problem exists only when I use webhook and try to call the /command manually
You have the error log activated? Also, in your webhook, make sure that the errors are logged properly in the catch block:
} catch (Longman\TelegramBot\Exception\TelegramException $e) {
// Log telegram errors
Longman\TelegramBot\TelegramLog::error($e);
}
@sup3rgiu why not trying to debug it by wrapping it in try...catch?
try {
$ig = new \InstagramAPI\Instagram($debug, $truncatedDebug);
} catch (\Exception $e) {
file_put_contents(__DIR__ . '/error.log', $e, FILE_APPEND);
}
@sup3rgiu why not trying to debug it by wrapping it in try...catch?
try { $ig = new \InstagramAPI\Instagram($debug, $truncatedDebug); } catch (\Exception $e) { file_put_contents(__DIR__ . '/error.log', $e, FILE_APPEND); }
The file is not created (obviously not permission problem).
It's like if the code immediatly stops at the $ig = new \InstagramAPI\Instagram($debug, $truncatedDebug);
line
@noplanman contacted me on Telegram and is investigating
This is a security feature from the Instagram API.
It only allows safe calls that come via CLI, which are both the case when you use getUpdates and cron. Webhook however, comes through the webserver, so it's blocked.
Simply call this somewhere at the beginning of your webhook:
\InstagramAPI\Instagram::$allowDangerousWebUsageAtMyOwnRisk = true;
Required Information
I'm using this to perform some actions on my Instagram account https://github.com/mgp25/Instagram-API/.
In the code of a telegram Command, I put
$ig = new \InstagramAPI\Instagram();
as requested by the API.while true; do ./Bot.php; done
) everything works fine;$ig = new \InstagramAPI\Instagram();
something wrong happens since nothing after that line is executed. Example:I receive only "I'm Here" and not "I'm Here 2", and also
...code2...
is not executed.N.B: no errors are generated in the error log file