openPostFeed
Bắt đầu hỗ trợ ở phiên bản:
- API: 2.5.3
Lưu ý
Cần xin cấp quyền tại trang Quản lý ứng dụng
Cho phép ứng dụng mở giao diện chia sẻ để người dùng chia sẻ thông tin lên nhật ký Zalo.
Parameters
Object object
Property | Type | Default | Required | Description | Minimum Version |
---|---|---|---|---|---|
type | string | true | Nhận các giá trị sau:
| ||
data | object | true | Nội dung cần chia sẻ theo type | ||
success | function | Callback function khi gọi api thành công | |||
fail | function | Callback function khi gọi api thất bại n |
Object data
Chia sẻ hình ảnh (type='image')
Property | Type | Default | Required | Description | Minimum Version |
---|---|---|---|---|---|
imageUrl | string | true | url hình ảnh cần chia sẻ |
Chia sẻ liên kết (type='link')
Property | Type | Default | Required | Description | Minimum Version |
---|---|---|---|---|---|
link | string | true | Liên kết cần chia sẻ | ||
thumb | string | Thumbnail | |||
description | string | Mô tả | |||
title | string | Tiêu đề của liên kết |
Chia sẻ profile (type='profile')
Property | Type | Default | Required | Description | Minimum Version |
---|---|---|---|---|---|
id | string | true | Id của OA |
Return Values
Promise<Object data>
Property | Type | Description | Minimum Version |
---|---|---|---|
status | number | Có các giá trị sau:
| |
shareType | number | Trạng thái bài chia sẻ, có các giá trị sau:
| |
numberOfUser | number | Số lượng user nhận được bài chia sẻ trong trường hợp shareType=2 |
Sample Code
Chia sẻ hình ảnh
import api from 'zmp-sdk';
api.login({
success: () => {
api.openPostFeed({
type: 'image',
data: {
imageUrl: 'link-to-image'
},
success: (data) => {},
fail: (err) => {}
});
},
fail: (error) => {
console.log(error);
}
});
Chia sẻ liên kết
import api from 'zmp-sdk';
api.login({
success: () => {
api.openPostFeed({
type: 'link',
data: {
link: 'http://news.zing.vn/Trung-uong-quyet-dinh-phuong-an-nhan-su-cap-cao-post632739.html',
title: 'Trung ương quyết định phương án nhân sự cấp cao',
thumb: 'link-to-thumb',
description: 'description'
},
success: (data) => {},
fail: (err) => {}
});
},
fail: (error) => {
console.log(error);
}
});
Chia sẻ profile
import api from 'zmp-sdk';
api.login({
success: () => {
api.openPostFeed({
type: 'profile',
data: {
avatar:
'http://s120.avatar.talk.zdn.vn/5/f/9/6/27/120/33a07b66a06fd78ba5e645a750f3d72b.jpg',
id: '765465772305886642',
displayName: 'Galaxy Cinema'
},
success: (data) => {},
fail: (err) => {}
});
},
fail: (error) => {
console.log(error);
}
});