/** * sharePostChannel * * @param string $message Param * @param object &$channel Param * @param object &$post Param * * @return array */ protected function sharePostChannel($message, &$channel, &$post) { // Send message $attempt = 0; $resend_attempts = $this->resend_attempts; $response = array('state' => AutotweetPostHelper::POST_ERROR, 'result_msg' => 'COM_AUTOTWEET_ERR_CHANNEL_UNPROCESSED'); // Post message for channel; multiple attempts if needed do { $resend = false; $attempt++; $this->logger->log(JLog::INFO, "sharePostChannel - Message ({$attempt} / {$resend_attempts}): ", $message); // {$post->id} ({$post->plugin},{$post->ref_id})" $this->logger->log(JLog::INFO, "sharePostChannel - Post ({$attempt} / {$resend_attempts}): " . json_encode($post)); // Post to channel, et the result code $result_status = $channel->sendMessage($message, $post); if ($attempt < $this->resend_attempts && !$result_status[0]) { $resend = true; $this->logger->log(JLog::WARNING, 'sendRequest: ' . $channel->getChannelType() . ':' . $channel->getChannelName() . ' - service unavailable or timeout, return code = ' . $result_status[1] . ' - sending message again in ' . self::RESEND_DELAY . ' seconds'); sleep(self::RESEND_DELAY); } } while ($resend); $result_msg = $result_status[1]; $response['result_msg'] = $result_msg; if ($result_status[0]) { $response['state'] = AutotweetPostHelper::POST_SUCCESS; $this->logger->log(JLog::INFO, 'sendRequest: ' . $channel->getChannelType() . ':' . $channel->getChannelName() . ' - status has been updated, ref_id = ' . $post->ref_id . ' (attempts: ' . $attempt . ')'); } else { $response['state'] = AutotweetPostHelper::POST_ERROR; $this->logger->log(JLog::ERROR, 'sendRequest: error when sending message to ' . $channel->getChannelType() . ':' . $channel->getChannelName() . ', - ref_id = ' . $post->ref_id . ', return code = ' . $result_status[1]); TextUtil::adminNotification($channel->getChannelName(), $result_msg, $post); } return $response; }