Recent Topics

1 Jan 22, 2017 13:42    

Hi, like the title, exist an app to integrate with b2evolution? (for read post, for receiver notification of new post or comment and any other things to do on blog)
If not exist, where i can find the api for make it whit my hands?

3 Jan 22, 2017 18:04

This is a very good news, the library used with my project use rest api in json to, this make all more simple (I no need to re-write anything <3<3).
thanks bro for the good info, and obviously thanks for the fast reply!!!

4 Jan 22, 2017 21:21

sorry for the double post, i have found all, but I have a problem... the system status of the blog report an issue:

REST API Failed
blogurl/api/v6/collections
This API doesn't work properly on this server. Probably you should update a file .htaccess to the latest version or check permissions to use this file. Error: unserialize(): Error at offset 0 of 1 bytes

at the moment on my server is in use php7 probably a problem with with some module mentioned on .htaccess, but which?

5 Jan 23, 2017 08:34

in sample file I've found an extra line related to rest api that there was not in my .htaccess file, i added it to my .htaccess file and now all green!
I had not thought to check the sample.htaccess, thanks, you saved me.

7 Apr 20, 2018 12:07

I've started again to work on the app, but for necessity I modified the Rest Api a little, because before the modification without set an ID for a post it return the posts list with all content and attachment and the json response returned is too big to be handled.

So from line 680 of of v6 api available in latest update:

$item_data = array(
                    'id'          => intval( $Item->ID ),
                    'datestart'   => $Item->get( 'datestart' ),
                    'urltitle'    => $Item->get( 'urltitle' ),
                    'type'        => $Item->get_type_setting( 'name' ),
                    'title'       => $Item->get( 'title' ),
                    'content'     => $Item->get_prerendered_content( 'htmlbody' ),
                    'excerpt'     => $Item->get( 'excerpt' ),
                    'teaser'      => $Item->get_content_teaser(),
                    'URL'         => $Item->get_permanent_url( '', '', '&' ),
                    'attachments' => $attachments,
                );

            if( $post_ID )
            {   // If only one post is requested then response should as one level array with post fields:
                $this->response = $item_data;
            }

I've modified it in:

$item_data = array(
                    'id'          => intval( $Item->ID ),
                    'datestart'   => $Item->get( 'datestart' ),
                    'urltitle'    => $Item->get( 'urltitle' ),
                    'type'        => $Item->get_type_setting( 'name' ),
                    'title'       => $Item->get( 'title' ),
                    /* 'content'     => $Item->get_prerendered_content( 'htmlbody' ),
                    'excerpt'     => $Item->get( 'excerpt' ),
                    'teaser'      => $Item->get_content_teaser(),*/
                    'URL'         => $Item->get_permanent_url( '', '', '&' ),
                    /*'attachments' => $attachments, */
                );

            if( $post_ID )
            {   // If only one post is requested then response should as one level array with post fields:
                $item_data = array(
                    'id'          => intval( $Item->ID ),
                    'datestart'   => $Item->get( 'datestart' ),
                    'urltitle'    => $Item->get( 'urltitle' ),
                    'type'        => $Item->get_type_setting( 'name' ),
                    'title'       => $Item->get( 'title' ),
                    'content'     => $Item->get_prerendered_content( 'htmlbody' ),
                    'excerpt'     => $Item->get( 'excerpt' ),
                    'teaser'      => $Item->get_content_teaser(),
                    'URL'         => $Item->get_permanent_url( '', '', '&' ),
                    'attachments' => $attachments,
                );
                $this->response = $item_data;
            }

so in this way when I call "domain.com/api/v6/collections/collection-name/posts" it return only the essential information for make a list of available posts and when I call "domain.com/api/v6/collections/collection-name/posts/post-id" it response whit all information, content and attachment of the post.

i simply commented the unnecessary item just in case is needed to be reverted.

work on app proceed slowly but only because during the winter i don't work on my PC and because I progress at little step refinig the code generated before start a new step.
At the moment I work on GET section for retrive and handle content in app. next step is make a layout for handled content of GET operation, i don't know when is ready for a full functionality (GET and POST) but sure for the end of Summer the get section are ready and ca be used for read content from a site created with the b2evo CMS (or at least I hope)

8 Apr 20, 2018 14:41

I made another little modification to rest api for fit some my needs

from line 664 where we can fount the attachment array:

$attachments[] = array(
                                'link_ID'  => intval( $Link->ID ),
                                'file_ID'  => intval( $File->ID ),
                                'type'     => strval( $File->is_dir() ? 'dir' : $File->type ),
                                'position' => $Link->get( 'position' ),
                                'name'     => $File->get_name(),
                                'url'      => $File->get_url(),
                                'title'    => strval( $File->get( 'title' ) ),
                                'alt'      => strval( $File->get( 'alt' ) ),
                                'desc'     => strval( $File->get( 'desc' ) ),
                            );

I've modified it in this way

if (! $post_ID){
                        $attachments[] = array(
                                'type'     => strval( $File->is_dir() ? 'dir' : $File->type ),
                            );
                        }else{
                            $attachments[] = array(
                                'link_ID'  => intval( $Link->ID ),
                                'file_ID'  => intval( $File->ID ),
                                'type'     => strval( $File->is_dir() ? 'dir' : $File->type ),
                                'position' => $Link->get( 'position' ),
                                'name'     => $File->get_name(),
                                'url'      => $File->get_url(),
                                'title'    => strval( $File->get( 'title' ) ),
                                'alt'      => strval( $File->get( 'alt' ) ),
                                'desc'     => strval( $File->get( 'desc' ) ),
                            );
                        }

this because before load attachment data I need to know if I have an attachment and which type for ruote the response returned fron a get post to the correct handler.

and modified the response modified and posted previously for fit this modification so when post have at least 1 attachment response include a new parameter

'NumberOfAttachments' => count($attachments),

and attacments parameter return the list of attachment as usual but only its type (because I no need other stuff at the moment) else if the post doesn't have an attachment the new parameter gone and the attachment parameter return a general string

'attachments' => 'No attachments',

and when i call a single post are added even the new parameter and the attachment array return all data available for each attachament into the post.

if someone have something to tell regarding my modification or a way to retrive only data that I need in a different way I'm here, else, if into the api isn't available a way for remove specific parameter to be sended and you like my work, you can add it into current or future rest api release.

9 Apr 22, 2018 21:38

We'll check those mods. Thanks.

This post has 1 feedback awaiting moderation...


Form is loading...