Posted May 25, 20187 yr 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 ) )
May 29, 20187 yr 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 ?
May 29, 20187 yr Author 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.
May 30, 20187 yr 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 ? )
May 30, 20187 yr Author 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 Edited May 30, 20187 yr by zbahadir
Archived
This topic is now archived and is closed to further replies.