Nhảy tới nội dung

Bắt đầu hỗ trợ ở phiên bản:

  • SDK: 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​

PropertyTypeDefaultRequiredDescriptionMinimum Version
typestringtrueNhận các giá trị sau:
  • 'image': Chia sẻ hình ảnh
  • 'link': Chia sẻ liên kết
  • 'profile': Chia sẻ profile OA
dataobjecttrueNội dung cần chia sẻ theo type
successfunctionCallback function khi gọi api thành công
failfunctionCallback function khi gọi api thất bại n

Object data​

Chia sẻ hình ảnh (type='image')​
PropertyTypeDefaultRequiredDescriptionMinimum Version
imageUrlstringtrueurl hình ảnh cần chia sẻ
PropertyTypeDefaultRequiredDescriptionMinimum Version
linkstringtrueLiên kết cần chia sẻ
thumbstringThumbnail
descriptionstringMô tả
titlestringTiêu đề của liên kết
Chia sẻ profile (type='profile')​
PropertyTypeDefaultRequiredDescriptionMinimum Version
idstringtrueId của OA

Return Values​

Promise <Object data>​

PropertyTypeDescriptionMinimum Version
statusnumberCó các giá trị sau:
  • 0: User nhấn huỷ/cancel bài viết
  • 1: Đăng bài viết thành công
shareTypenumberTrạng thái bài chia sẻ, có các giá trị sau:
  • 0: Công khai
  • 1: Chỉ mình tôi
  • 2: Chia sẻ cho danh sách bạn
numberOfUsernumberSố 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 { openPostFeed } from "zmp-sdk/apis";

openPostFeed({
type: "image",
data: {
imageUrl: "link-to-image"
},
success: (data) => {},
fail: (err) => {}
});

Hoặc

import { openPostFeed } from "zmp-sdk/apis";

const shareImage = async () => {
try {
const data = await openPostFeed({
type: "image",
data: {
imageUrl: "link-to-image"
}
});
// xử lý chia sẻ hình ảnh thành công
} catch (err) {
// Xử lý lỗi
}
};

Chia sẻ liên kết​

import { openPostFeed } from "zmp-sdk/apis";

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) => {}
});

Hoặc

import { openPostFeed } from "zmp-sdk/apis";

const shareLink = async () => {
try {
const data = await 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"
}
});
// xử lý chia sẻ liên kết thành công
} catch (err) {
// Xử lý lỗi
}
};

Chia sẻ profile​

import { openPostFeed } from "zmp-sdk/apis";

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) => {}
});

Hoặc

import { openPostFeed } from "zmp-sdk/apis";

const shareProfile = async () => {
try {
const data = await 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"
}
});
// xử lý chia sẻ profile thành công
} catch (err) {
// Xử lý lỗi
}
};