コード例 #1
0
ファイル: blog.php プロジェクト: z445056647/phx-svns
            // 定时发送
            foreach ($wbs as $type) {
                $task->AddTask($type, $content, $_POST['send_time'], NULL, Task::TASK, NULL, 'blog', $_POST['title']);
            }
            $TEMPLATE['report']['time'] = array('status' => true, 'msg' => '定时发送成功!<a href="task.php">查看</a>');
        } else {
            $watch = new Stopwatch();
            $watch->Start();
            // 直接发送
            foreach ($wbs as $type) {
                $type_arr = explode('|', $type);
                $third = $thirdAccount->getByType($type_arr[0], $type_arr[1]);
                $api = Factory::CreateAPI2($type_arr[0], $type_arr[1], $third);
                $ret = $api->publish($_POST['title'], $content);
                if ($ret !== true && str_contains($ret, '已过期')) {
                    $thirdAccount->fail($third, $ret);
                }
                $TEMPLATE['report'][$type] = array('status' => $ret === true, 'msg' => $ret === true ? '发送成功!' . ($third['url'] ? '<a href="' . $third['url'] . '" target="_blank">查看</a>' : '') : '发送失败:' . $ret . ' <a href="list_err.php">重新发送</a>');
                $task->AddTask($type, $content, time(), NULL, $ret === true ? Task::OK : Task::ERROR, $ret, 'blog', $_POST['title']);
            }
            $watch->Stop();
            $TEMPLATE['report']['watch'] = array('status' => true, 'msg' => "总耗时:{$watch->getElapsedSeconds()} 秒");
        }
    }
}
$TEMPLATE['title'] = '发博客';
$TEMPLATE['login_name'] = Passport::GetLoginName();
$TEMPLATE['nav']['blog'] = 'current';
$TEMPLATE['target_list'] = $wt_open->getBlogList();
$TEMPLATE['platform_list'] = $wt_open->getPlatformList();
foreach ($TEMPLATE['platform_list'] as &$item) {