zbahadir Posted May 25, 2018 Posted May 25, 2018 I am developing a mobile app. In addition to the REST API -> Get list of posts, the topic_id parameter is much needed. I added myself to api / posts.php. /* Has best answer */ if ( isset( \IPS\Request::i()->hasBestAnswer ) ) { if ( \IPS\Request::i()->hasBestAnswer ) { $where[] = array( "topic_answered_pid>0" ); } else { $where[] = array( "topic_answered_pid=0" ); } } /* Topic ID */ if ( isset( \IPS\Request::i()->topicid ) ) { if ( \IPS\Request::i()->topicid ) { $where[] = array( "topic_id=".\IPS\Request::i()->topicid ); } else { $where[] = array( "topic_id=".\IPS\Request::i()->topicid ); } } /* Archived */ if ( isset( \IPS\Request::i()->archived ) )
bfarber Posted May 29, 2018 Posted May 29, 2018 Are you asking for a way to return posts belonging to a specific topic? If so, is there any reason you can't use GET api/topics/{topic-id}/posts ?
zbahadir Posted May 29, 2018 Author Posted May 29, 2018 it worked with this method. ? But some things are missing. For example I want to get post likes. I get this data with extra methods, but I want to get it with the API. Thank you so much.
bfarber Posted May 30, 2018 Posted May 30, 2018 Anything else besides post likes? (I'll be looking into REST API improvements for 4.4 so the more specifics you can provide, the more likely you are to see your requested changes incorporated ? )
zbahadir Posted May 30, 2018 Author Posted May 30, 2018 Thank you very much for your interest. I will have some suggestions. I will make a list. posts like/unlike posts image and file upload api members upload coverPhoto and photo/avatar upload api For example. For Forums: response parent_id can be added.I added this: applications / forums / api / forums.php: public function GETindex () { / * Init * / $ where = array (); if (isset (\ IPS \ Request :: i () -> parent)) { if (\ IPS \ Request :: i () -> parent) { $ where [] = array ("parent_id =". \ IPS \ Request :: i () -> parent); } else { $ where [] = array ("parent_id =". \ IPS \ Request :: i () -> parent); } } / * Return new * / return $ this -> _ list ($ where, 'forums'); } and response likes total for post public function apiOutput( \IPS\Member $authorizedMember = NULL ) { $idColumn = static::$databaseColumnId; $itemColumn = static::$databaseColumnMap['item']; return array( 'id' => $this->$idColumn, 'item_id' => $this->$itemColumn, 'author' => $this->author()->apiOutput( $authorizedMember ), 'date' => \IPS\DateTime::ts( $this->mapped('date') )->rfc3339(), 'content' => $this->content(), 'hidden' => (bool) $this->hidden(), 'url' => (string) $this->url(), 'likes' => \IPS\Db::i()->select( 'COUNT(*)', 'core_reputation_index', array( 'type_id=?', (int) $this->$itemColumn ) )->first(), ); } I will prepare the missing ones for a mobile application. Best Regards
Recommended Posts
Archived
This topic is now archived and is closed to further replies.