owned this note
owned this note
Published
Linked with GitHub
# Blog API 文件
## Auth (授權)
### /v1/auth/login
**使用者登入**
- method
- POST
- headers
- Content-Type
- application/json
- parameters
- email
- password
- request
```jsonid=
{
"email":"liuliufunfun@gmail.com",
"password":"123456"
}
```
- response
```jsonid=
{
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9iNjk3NjUzNi5uZ3Jvay5pb1wvdjFcL2F1dGhcL2xvZ2luIiwiaWF0IjoxNTg3NDI3ODEzLCJleHAiOjE1ODc0MzE0MTMsIm5iZiI6MTU4NzQyNzgxMywianRpIjoiNkkzRmQ1bWRQc0xwUlVjSCIsInN1YiI6MywicHJ2IjoiYmYwMTU5MjQ2NGI2ZDNhMTY1Mzg3MTZiMzA5MmUxNjZmY2M2NmRkYiJ9.2DLClIUX-XxR8AXxTjj6ZETAMAFyL75lUj-3INb1YcA",
"token_type": "bearer",
"expires_in": 3600
}
```
---
### /v1/auth/register
**使用者註冊**
- method
- POST
- headers
- Content-Type
- application/json
- parameters
- user_name
- email
- password
- request
```jsonid=
{
"user_name":"liuliu",
"email":"liuliufunfun@gmail.com",
"password":"123456"
}
```
- response
```string=
"OK"
```
- error
```jsonid=
{
"error_code": 400,
"message": "已經是會員囉!!"
}
```
---
### /v1/auth/reset-password
**使用者更改密碼**
- method
- POST
- headers
- Content-Type
- application/json
- parameters
- email
- password
- request
```jsonid=
{
"email":"liuliufunfun@gmail.com",
"password":"123456"
}
```
- response
```string=
{
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9iNjk3NjUzNi5uZ3Jvay5pb1wvdjFcL2F1dGhcL3Jlc2V0LXBhc3N3b3JkIiwiaWF0IjoxNTg3NDMxNzcwLCJleHAiOjE1ODc0MzUzNzAsIm5iZiI6MTU4NzQzMTc3MCwianRpIjoid0hGN21uMG9CS0JJb3E3VCIsInN1YiI6MSwicHJ2IjoiYmYwMTU5MjQ2NGI2ZDNhMTY1Mzg3MTZiMzA5MmUxNjZmY2M2NmRkYiJ9.Wgm6C7L_oojFfWNmT-4wfZMRVn7LW7mlin05yudfG9I",
"token_type": "bearer",
"expires_in": 3600
}
```
- error
```jsonid=
{
"error_code": 400,
"message": "您尚未成為會員"
}
```
---
### /v1/auth/register
**使用者註冊**
- method
- POST
- headers
- Content-Type
- application/json
- parameters
- user_name
- email
- password
- request
```jsonid=
{
"user_name":"liuliu",
"email":"liuliufunfun@gmail.com",
"password":"123456"
}
```
- response
```string=
"OK"
```
- error
```jsonid=
{
"error_code": 400,
"message": "已經是會員囉!!"
}
```
---
### /v1/auth/me
**使用者資料**
- method
- GET
- headers
- Content-Type
- application/json
- Authorization
- Bearer-Token
- response
```jsonid=
{
"id": 3,
"user_name": "liuliu",
"email": "liuliufunfun@gmail.com",
"password": "$2y$10$tjDeT0qr4RQaCfelt7VMAu8nZWzNGWozo.a6lxxPdRlwdhgJY0pui",
"created_at": "2020-04-19T10:49:55.000000Z",
"updated_at": "2020-04-19T10:49:55.000000Z"
}
```
- error
```jsonid=
{}
```
---
## Articles (文章資訊)
### /v1/articles
**取得所有可見文章**
- method
- GET
- headers
- Authorization
- Bearer-Token
- parameters
- limit
- response
```jsonid=
[
{
"id": 5,
"title": "test",
"content": "Yes I got it. GOOD.",
"tags": [
"cc",
"d"
]
}
]
```
- error
```jsonid=
{}
```
---
### /v1/articles/{:article_id}
**取得特定文章**
- method
- GET
- headers
- Authorization
- Bearer-Token
- response
```jsonid=
{
"id": 2,
"title": "123",
"content": "create success.",
"tags": [
"a",
"b",
"c"
]
}
```
- error
```jsonid=
{
"error_code": 403,
"message": "403 Forbidden."
}
{
"error_code": 404,
"message": "404 Not Found."
}
```
---
### /v1/articles
**新增文章**
- method
- POST
- headers
- Content-Type
- application/json
- Authorization
- Bearer-Token
- parameters
- title
- content
- tag [optional]
- request
```jsonid=
{
"title":"tired",
"content":"create success.",
"tag":["a", "b", "c", "e", "f"]
}
```
- response
```string=
OK
```
- error
```jsonid=
{
"error_code": 400,
"message": "請輸入文章標題"
}
```
---
### /v1/articles/{:article_id}
**修改文章**
- method
- PUT
- headers
- Content-Type
- application/json
- Authorization
- Bearer-Token
- parameters
- title [optional, 若沒有其他欄位則必填]
- content [optional, 若沒有其他欄位則必填]
- tag [optional, 若沒有其他欄位則必填]
- request
```jsonid=
{
"title":"test",
"content":"Yes I got it. GOOD.",
"tag":["cc","d","a"]
}
```
- response
```string=
OK
```
- error
```jsonid=
{
"error_code": 403,
"message": "403 Forbidden."
}
```
---
### /v1/articles/{:article_id}
**刪除文章**
- method
- DELETE
- headers
- Authorization
- Bearer-Token
- response
```jsonid=
"OK"
```
- error
```jsonid=
{
"error_code": 404,
"message": "404 Not Found."
}
```
---
## Carts (購物車)
### /v1/carts
**新增商品,並回傳購物車內容**
- method
- POST
- headers
- Content-Type
- application/json
- Authorization
- Bearer-Token
- parameters
- article_ids [array]
- request
```jsonid=
{
"article_ids":[3, 4, 5]
}
```
- response
```string=
{
"items": {
"3": {
"id": 3,
"name": "123",
"price": 50,
"quantity": 1,
"attributes": [],
"conditions": []
},
"4": {
"id": 4,
"name": "123",
"price": 0,
"quantity": 1,
"attributes": [],
"conditions": []
},
"5": {
"id": 5,
"name": "test",
"price": 0,
"quantity": 1,
"attributes": [],
"conditions": []
}
}
}
```
- error
```jsonid=
{
"error_code": 400,
"message": "缺少購買品項"
}
```
---
## Payments (付款金流)
### /v1/payments
**串接藍新金流,付款**
- method
- POST
- headers
- Content-Type
- application/json
- Authorization
- Bearer-Token
- parameters
- article_ids [array]
- payment_method (ATM, CREDIT_CARD, CVS)
- request
```jsonid=
{
"article_ids":[1, 2, 3, 4, 5],
"payment_method":"ATM"
}
```
- response
```jsonid=目前只有串接 ATM,但是 notifyURL 沒有被觸發,原因待查=
{
"status": 200,
"content": null
}
```
---
### /v1/payment-notify
**紀錄付款回傳資訊並開立發票**
- method
- POST
- headers
- Content-Type
- application/x-www-form-urlencoded
- parameters
- order_no
- request
```form_params=
order_no:OD_31587430023
```
- response
```jsonid=API串接有誤,問題待查,期間內無可用合約,因付款API串接未完成,故紀錄付款回傳資訊待辦=
{
"url": "https://cinv.pay2go.com/Api/invoice_issue",
"sent_parameter": "MerchantID_=32332197&PostData_=39f91a70ac4119fdc6cf6131dc9013548672edfd76256fb8c0b370c53bf5499937a90c0a0f9e1786fb4d2f8fbcd8bc9467082b86fbf5f15c55bd4f8ecba025850a5fb16b1e986939b42bbf22d36f0c16fa791c4b41df5815f9c446a4221fb9c1fa0638467828cea33025b534c9cb4830ce6664aa43c89c554f8c70da5f312172552beb57ad050805b0e5503611986ca5a7edf6d488d76b83fa01cddc79443cd22cbd53ad80b1aaa524a30d4f3d5145348798596a3225b7a12f63e511b17d25c85c33b974451b519bfcd552681a73f980f137ce0fead8aef95ca638155f4f029a2005477cfe7b7f88b637b0832ebc4f4177df00f67cce58e414e954d15ed0c5f35ff8e792efd078d4be13e32a30666f656767d56fcefb8b6c7d5a9518b1630cc75fd04faf214dd8b9cf1b9c26a4a96d6280e420d78c07e73623d64b9da77acdaa99f422bb5e0bf874ce98b58925baca75b60c96df1bb815be63ebdaf111ec1766",
"http_status": 200,
"curl_error_no": 0,
"web_info":"{\"Status\":\"INV90005\",\"Message\":\"\期\間\內\無\可\用\合\約\",\"Result\":[]}"
}
```
---