githubjeka / yii2-rest

Yii2 REST API template
Other
159 stars 76 forks source link

how to get posts with this api? #14

Open sarinsurendran opened 8 years ago

sarinsurendran commented 8 years ago

http://localhost/api-template1/rest/web/v1/posts

shows http://prntscr.com/bpfq9v

githubjeka commented 8 years ago

https://github.com/githubjeka/yii2-rest/issues/9#issuecomment-132991019 https://github.com/githubjeka/yii2-rest/issues/11

githubjeka commented 8 years ago

And https://github.com/githubjeka/yii2-rest/issues/6#issuecomment-101134848

sarinsurendran commented 8 years ago

This is the login api right.. I need how to get posts with authorisation. It shows unauthorized.

githubjeka commented 8 years ago

See https://github.com/githubjeka/yii2-rest/blob/master/rest/versions/v1/controllers/PostController.php#L16-L18

You should send an access token for every request. The token is response from login (see the response https://github.com/githubjeka/yii2-rest/issues/6#issuecomment-101134848)

Read more about authentication in http://www.yiiframework.com/doc-2.0/guide-rest-authentication.html (Query parameter)

sarinsurendran commented 8 years ago

Ok. If that is the case we have to pass only the token with request right. No need of passing username and password. Can you just send me the screen shot for posts request to clear the idea.

githubjeka commented 8 years ago

Yes

Get token:

image

Get posts:

image

sarinsurendran commented 8 years ago

Ok thanks for your comments githubjeka.