Esempio n. 1
0
    if ($article['acc_id'] != $account['acc_id']) {
        return Helper::response(false, array(), 'Forbidden, article belongs to different account', 403);
    }
    $patched = ArticleModel::patchArticle($article['acc_id'], array('art_title' => $app->request->post('art_title', ''), 'art_body' => $app->request->post('art_body', '')));
    if (!$patched) {
        return Helper::response(false, array(), 'Application error', 500);
    }
    return Helper::response(true);
});
$app->post('/api-v1.0/article/delete/', function () use($app) {
    if (!($account = Helper::checkSecret())) {
        return;
    }
    $artId = $app->request->post('art_id');
    if (empty($artId)) {
        return Helper::response(false, array(), 'Bad request, art_id required', 400);
    }
    $article = ArticleModel::getArticle($artId);
    if (empty($article)) {
        return Helper::response(false, array(), 'Article not found', 404);
    }
    if ($article['acc_id'] != $account['acc_id']) {
        return Helper::response(false, array(), 'Forbidden, article belongs to different account', 403);
    }
    $deleted = ArticleModel::deleteArticle($article['art_id']);
    if (!$deleted) {
        return Helper::response(false, array(), 'Application error', 500);
    }
    FB::log($deleted);
    return Helper::response(true);
});
Esempio n. 2
0
<?php

use FB;
use My\Helper;
$app->get('/api-v1.0/', function () use($app) {
    Helper::response(true, array('version' => '1.0'));
});