Class Socialveo\WebApi\Controllers\PostsController

InheritanceSocialveo\WebApi\Controllers\PostsController » Socialveo\WebApi\Controllers\RestApiController » Phalcon\Mvc\Controller
Uses TraitsSocialveo\Core\Translatable

Class PostsController

Public Methods

Hide inherited methods

MethodDescriptionDefined By
_handleException() Handle exceptions Socialveo\WebApi\Controllers\RestApiController
_t() Gets translations Socialveo\Core\Translatable
afterExecuteRoute() After execute route, change return value to json Socialveo\WebApi\Controllers\RestApiController
beforeExecuteRoute() Before execute route, remove extra params Socialveo\WebApi\Controllers\RestApiController
checkClientCredentials() Checks client credentials Socialveo\WebApi\Controllers\RestApiController
commentsAction() Return a lists of comments associated with the given post Socialveo\WebApi\Controllers\PostsController
createAction() Creates a post Socialveo\WebApi\Controllers\PostsController
createCommentAction() Create comment on post Socialveo\WebApi\Controllers\PostsController
decrypt() Decrypt value Socialveo\WebApi\Controllers\RestApiController
deleteAction() Removes a post resource Socialveo\WebApi\Controllers\PostsController
emotionsAction() Return a lists of emotions associated with the given post Socialveo\WebApi\Controllers\PostsController
encrypt() Encrypt value Socialveo\WebApi\Controllers\RestApiController
getAction() Returns a post Socialveo\WebApi\Controllers\PostsController
getArrayFromParam() Returns array from params Socialveo\WebApi\Controllers\RestApiController
getLanguage() Gets language code Socialveo\WebApi\Controllers\RestApiController
getParams() Gets request params for Socialveo::filteredFind() Socialveo\WebApi\Controllers\RestApiController
getRequestData() Returns request data Socialveo\WebApi\Controllers\RestApiController
getRequiredParam() Get required param Socialveo\WebApi\Controllers\RestApiController
getToken() Get token Socialveo\WebApi\Controllers\RestApiController
getTranslation() Gets translations Socialveo\WebApi\Controllers\RestApiController
handleError() Handle errors Socialveo\WebApi\Controllers\RestApiController
handleException() Handle exceptions Socialveo\WebApi\Controllers\RestApiController
initialize() Initialize controller Socialveo\WebApi\Controllers\RestApiController
invalidMethodAction() Action trigger when invalid action tried run Socialveo\WebApi\Controllers\RestApiController
listAction() Return a lists of user homepage posts. The requesting user UUID is retrieved from Token/Session Socialveo\WebApi\Controllers\PostsController
notFoundAction() Not found action Socialveo\WebApi\Controllers\RestApiController
posts() Gets posts Socialveo\WebApi\Controllers\RestApiController
replaceParam() Replace param Socialveo\WebApi\Controllers\RestApiController
reportAction() Report a spam Socialveo\WebApi\Controllers\PostsController
repostAction() Re-posts post on network Socialveo\WebApi\Controllers\PostsController
respondWithItem() Response with item // * @deprecated Socialveo\WebApi\Controllers\RestApiController
sendJsonContent() Send response as json content and exit Socialveo\WebApi\Controllers\RestApiController
sendJsonContentRaw() Send json content Socialveo\WebApi\Controllers\RestApiController
sendJsonContentRawStatic() Send json content static Socialveo\WebApi\Controllers\RestApiController
setDefaultParam() Set default option Socialveo\WebApi\Controllers\RestApiController
socialRepostAction() Re-posts a post's body to a social profile provider Socialveo\WebApi\Controllers\PostsController
t() Gets translations Socialveo\Core\Translatable
tagsAction() Return a lists of tags associated with the given post Socialveo\WebApi\Controllers\PostsController
unsetParam() Unset get param Socialveo\WebApi\Controllers\RestApiController
updateAction() Updates a post Socialveo\WebApi\Controllers\PostsController

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
checkAccess() Checks during the init of controller whether user is a guest. Socialveo\WebApi\Controllers\RestApiController
log() Log full request data for debug Socialveo\WebApi\Controllers\RestApiController
objectsToArray() Convert objects to arrays Socialveo\WebApi\Controllers\RestApiController

Method Details

commentsAction() public method

Return a lists of comments associated with the given post

/posts/{post_uuid}/comments

Method: GET

Access: Owner || UserHasAccess

Parameters:

{post_uuid} required string post uuid
page or offset optional integer page start or offset
limit optional integer page limit
sortby[property]=order optional array sort by property value, order either desc or asc
filterby[property][operator]=value optional array filter by given property, operator eq (=), gt (>), ge(>=), lt(<), le(<=), ne(<>), like
uuids optional array or string list of item UUIDs to fetch, array or string separated by commas. when used, no other parameters can be utilized
language optional string language code

Filter by: Comment

Returns: Comment []

Sample response:

{
    "status": "OK",
    "data":[
        {"type": "comment", "uuid": "3e399f50-6ce8-11e7-8dd8-54bef75c7a3f", "user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",…},
        {"type": "comment", "uuid": "da779936-6ce7-11e7-964a-54bef75c7a3f", "user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",…},
        {"type": "comment", "uuid": "d36068e4-6ce7-11e7-a85c-54bef75c7a3f", "user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",…}
        {"type": "comment", "uuid": "d36068e4-6ce7-11e7-a85c-54bef75c7a3f", "user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",…}
        ...
    ],
    "count":{"offset": 0, "limit": 10, "total": 12},
    "timestamp": 1234567890
}

public mixed commentsAction ( $post_uuid )
$post_uuid string

Post UUID is passed in the request URI

createAction() public method

Creates a post

/posts/create/{network_uuid}

Method: POST

Access: Owner || ( Logged && UserHasAccess )

Parameters:

{network_uuid} required string the UUID of the network to post to
post_type required string type of post (eg. post message poll or draft etc.)
body required string the body of the post
shared_user_uuid optional string the UUID of the user who is the original author of the post (from whom the post was shared)
associations.tags optional mixed tags associated with the post, an array of tag UUIDs
associations.media optional mixed media associated with the post, an array of media UUIDs
**media_uuids optional mixed array or string separated by commas of media UUIDs

Affects: Post

Returns: Post

Sample response:

{
    "status": "OK",
    "data":{
        "type": "post",
        "uuid": "0d76c9e0-b5f9-11e4-9f4b-b88d1200a92c",
        "user_uuid": "0bb0c9f8-b5f9-11e4-b2e9-b88d1200a92c",
        "network_uuid": "0be7129c-b5f9-11e4-bb84-b88d1200a92c",
        "post_type": "post",
        ...
    },
    "timestamp": 1234567890
}

public mixed createAction ( $network_uuid )
$network_uuid string

Network uuid

createCommentAction() public method

Create comment on post

/posts/{post_uuid}/create-comment

Method: POST

Access: Owner || UserHasAccessComment

Parameters:

{post_uuid} required string post uuid
body required string comment body
attributes optional mixed Comment attributes

Affects: Comment , Media , Tag , TagAssociation

Returns: Comment

Sample response:

{
    "status": "OK",
    "data":[
        'uuid': '3783fb66-b5e7-11e4-b252-b88d1200a92c',
        'user_uuid': '32067218-b5e7-11e4-a722-b88d1200a92c',
        'target_uuid': '347d7974-b5e7-11e4-a4e3-b88d1200a92c',
        'parent_uuid': null,
        ...
    ],
    "timestamp": 1234567890
}

public mixed createCommentAction ( $post_uuid )
$post_uuid string

Post UUID is passed in the request URI

throws Exception
deleteAction() public method

Removes a post resource

/posts/{post_uuid}/delete

Method: POST

Access: Owner

Parameters:

{post_uuid} required string post uuid

Affects: Post

Sample response:

{
    "status": "OK",
    "timestamp": 1234567890
}

public mixed deleteAction ( $post_uuid )
$post_uuid string

Post UUID is passed in the request URI

emotionsAction() public method

Return a lists of emotions associated with the given post

/posts/{post_uuid}/emotions

Method: GET

Access: Owner || UserHasAccess (Post)

Parameters:

page or offset optional integer page start or offset
limit optional integer page limit
sortby[property]=order optional array sort by property value, order either desc or asc
filterby[property][operator]=value optional array filter by given property, operator eq (=), gt (>), ge(>=), lt(<), le(<=), ne(<>), like
emotion optional string filter by emotion, defined in config, (default is sad, like, angry, boring, love, dislike)
language optional string language code

Filter by: TagAssociation

Returns: array[]

Sample response:

{
    "status": "OK",
    "data":[
        {"user_uuid": "4622f77e-27f8-11e6-98d1-54bef75c7a3f", "fullname": "Simpson Homer", "avatar": "http://api.socialveo.dev//data/4631a06c-27f8-11e6-94b3-54bef75c7a3f/bbe4cc0da7651ede420d8bfd32b4c1b9.jpg",…},
        {"user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f", "fullname": "Andy Izman", "avatar": "http://api.socialveo.dev//data/a66b8654-14a8-11e6-af87-54bef75c7a3f/ed33d2d155baffbd2c5c2231761ee411.jpg",…}
        ...
    ],
    "counts":{"sad": 1, "like": 1, "angry": 0, "boring": 0, "love": 0,…},
    "count":{"offset": 0, "limit": 10, "total": 12},
    "timestamp": 1234567890
}

public mixed emotionsAction ( $post_uuid )
$post_uuid string

Post UUID is passed in the request URI

getAction() public method

Returns a post

/posts/{post_uuid}

Method: GET

Access: Owner || UserHasAccess

Parameters:

{post_uuid} required string post uuid
embed optional mixed allows to include one or more child resource(s) in the response

Returns: Post

Sample response:

{
    "status": "OK",
    "data":{
        'uuid': '0d76c9e0-b5f9-11e4-9f4b-b88d1200a92c',
        'user_uuid': '0bb0c9f8-b5f9-11e4-b2e9-b88d1200a92c',
        'network_uuid': '0be7129c-b5f9-11e4-bb84-b88d1200a92c',
        'post_type': 'post',
        ...
    },
    "timestamp": 1234567890
}

public mixed getAction ( $post_uuid )
$post_uuid string

Post UUID is passed in the request URI

listAction() public method

Return a lists of user homepage posts. The requesting user UUID is retrieved from Token/Session

/posts

Method: GET

Access: Public

Parameters:

page or offset optional integer page start or offset
limit optional integer page limit
sortby[property]=order optional array sort by property value, order either desc or asc
filterby[property][operator]=value optional array filter by given property, operator eq (=), gt (>), ge(>=), lt(<), le(<=), ne(<>), like
uuids optional string or array list of item UUIDs to fetch, array or string separated by commas, when it used other parameters will be ignored
language optional string language code

Notes: When uuids param used then will be ignored others filter params

Filter by: Post

Returns: Post []

Sample response:

{
    "status": "OK",
    "data":[
        {"type": "posts", "uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f", "network_uuid": "a66b8654-14a8-11e6-af87-54bef75c7a3f",…},
        {"type": "posts", "uuid": "5a15e760-27ed-11e6-8d4a-54bef75c7a3f", "network_uuid": "5ac94e9a-27ed-11e6-9916-54bef75c7a3f",…},
        {"type": "posts", "uuid": "0449c1f2-27f8-11e6-be68-54bef75c7a3f", "network_uuid": "04577e6e-27f8-11e6-b0cf-54bef75c7a3f",…},
        {"type": "posts", "uuid": "4622f77e-27f8-11e6-98d1-54bef75c7a3f", "network_uuid": "4631a06c-27f8-11e6-94b3-54bef75c7a3f",…},
        ...
    ],
    "count":{"offset": 0, "limit": 10, "total": 12},
    "timestamp": 1234567890
}

public mixed listAction ( )
reportAction() public method

Report a spam

/posts/{post_uuid}/report

Method: POST

Access: Logged && NotOwner && UserHasAccess (Post passed by _{post_uuid}_)

Parameters:

{post_uuid} required string post uuid
type optional string spam type
language optional string language code

Affects: Post , Spam

Returns: Spam

Sample response: ```json

{ "status": "OK", "data":{ 'uuid': '0d76c9e0-b5f9-11e4-9f4b-b88d1200a92c', 'user_uuid': '0bb0c9f8-b5f9-11e4-b2e9-b88d1200a92c', 'target_type': 'post', 'target_uuid': '0be7129c-b5f9-11e4-bb84-b88d1200a92c', ... }, "timestamp": 1234567890 }

public mixed reportAction ( $post_uuid )
$post_uuid string

Post UUID is passed in the request URI

throws Exception
repostAction() public method

Re-posts post on network

/posts/{post_uuid}/repost

Method: POST

Access: Owner || ( Logged && UserHasAccess )

Note. For sending media files request content-type have to be *multipart/form-data*

Parameters:

{post_uuid} required string post uuid
network_uuid required string network in which post will be posted
media optional mixed media files to be uploaded
embed optional mixed embed contents
body required string the post body

Affects: Post

Returns: Post

Sample response:

{
    "status": "OK",
    "data":{
        'uuid': '0d76c9e0-b5f9-11e4-9f4b-b88d1200a92c',
        'user_uuid': '0bb0c9f8-b5f9-11e4-b2e9-b88d1200a92c',
        'network_uuid': '0be7129c-b5f9-11e4-bb84-b88d1200a92c',
        'post_type': 'post',
        ...
    },
    "timestamp": 1234567890
}

public mixed repostAction ( $post_uuid )
$post_uuid string

Post UUID is passed in the request URI

throws Exception
socialRepostAction() public method

Re-posts a post's body to a social profile provider

Notice. This action is disabled, the reasons can be: not implemented, unsafe, duplicated or deprecated (autodetect: disabled in the router)
/posts/{post_uuid}/social-repost

Method: POST

Access: Owner || ( Logged && UserHasAccess )

Parameters:

{post_uuid} required string post uuid
provider required string provider name, e.g. Facebook, Google, etc

Sample response:

{
    'status': 'OK',
    "timestamp": 1234567890
}

public mixed socialRepostAction ( $post_uuid )
$post_uuid string

Post UUID is passed in the request URI

throws Exception
tagsAction() public method

Return a lists of tags associated with the given post

/posts/{post_uuid}/tags

Method: GET

Access: Owner, UserHasAccess

Parameters:

{post_uuid} required string post uuid
page or offset optional integer page start or offset
limit optional integer page limit
sortby[property]=order optional array sort by property value, order either desc or asc
filterby[property][operator]=value optional filter by given property, operator eq (=), gt (>), ge(>=), lt(<), le(<=), ne(<>), like
uuids optional list of item UUIDs to fetch, array or string separated by commas. when used, no other parameters can be utilized
language optional string, language code

Filter by: Tag

Returns: Tag []

Sample response:

{
    "status": "OK",
    "data":[
        {"type": "tag", "uuid": "3e399f50-6ce8-11e7-8dd8-54bef75c7a3f", "user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",…},
        {"type": "tag", "uuid": "da779936-6ce7-11e7-964a-54bef75c7a3f", "user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",…},
        ...
    ],
    "count":{"offset": 0, "limit": 10, "total": 12},
    "timestamp": 1234567890
}

public mixed tagsAction ( $post_uuid )
$post_uuid string

Post UUID is passed in the request URI

updateAction() public method

Updates a post

/posts/{post_uuid}/update

Method: POST

Access: Owner

Parameters:

{post_uuid} required string post uuid
attribute optional mixed Post attributes and values for update model

Affects: Post

Returns: Post

Sample response:

{
    "status": "OK",
    "data":{
        "type": "post",
        'uuid': '0d76c9e0-b5f9-11e4-9f4b-b88d1200a92c',
        'user_uuid': '0bb0c9f8-b5f9-11e4-b2e9-b88d1200a92c',
        'network_uuid': '0be7129c-b5f9-11e4-bb84-b88d1200a92c',
        'post_type': 'post',
        ...
    },
    "timestamp": 1234567890
}

public mixed updateAction ( $post_uuid )
$post_uuid string

Post UUID is passed in the request URI