Topic: CuteNews API

How to use the API to add news to the site without using the built-in editor ? With the ability to specify and additional fields.

2 (edited by 2014-09-18 20:27:19)

Re: CuteNews API

But when you add a record to the database , it is assigned id = 0 and post is added to the end of the base ??

<?php
$id = time();
$data = array(
    "t" => "Заголовок записи", // title
    "s" => "Короткая запись новости..", //short story
    "f" => "полная запись новости", // full story
    "c" => "3", // set category
    "u" => "Bukreevladimir", // set author
    "ht" => "1", // ...?
    "mf" => Array(
                "picpost" => "", // additional field's
                "importante" => "Y", // additional field's
                "videopost" => "", // additional field's
            ),
);
require_once 'vbase/cn_api.php';
cn_api_add_news($id, $data)
?>

Re: CuteNews API

Support Team, help?

Added post through the API. In the list of all the posts it appears at the bottom. Why ?
After clicking Edit News, the post is correct, as the most recent entries at the top.

Help! Because no information on the API.

Re: CuteNews API

You're doing everything right. You need to modify the API code. For that, you need to edit cn_api.php in Cutenews root.
Delete the following lines:

// add index data
    $w = fopen(db_index_file_detect(), 'a+');
    fwrite($w, base_convert($id, 10, 36).':'.$data['c'].':'.base_convert($user['id'], 10, 36).':'.count($data['co']).'::'."\n");
    fclose($w);

And replace them with:

db_index_add($id, $data['c'], $user['id'], $data['is_draft']);

In this case, the index will be build correctly.

Best regards,
CN Support team

Re: CuteNews API

Thank you, it works! I would like the next version to see callback that would like to know added entry or error.