![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Zalo SDK is a library of functions that support Zalo Login and call OpenAPI. With Zalo SDK, you can easily use Open APIs of Zalo.
These instructions will get you a copy of the project up and run on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Install with:
npm install --save zalo-sdk
And import to your project:
// Using require() in ES5
var Zalo = require('zalo-sdk');
Provides a way for your application to access data on Zalo's platform. Through the HTTP protocol, applications can query user data, friend data, post new information, and more.
To use the Social API, you need to register for the application on Zalo and follow the terms of Zalo. Click to view Zalo Developer Documentation For Open API.
Create an instance of the ZaloSocial class
var ZaloSocial = require('zalo-sdk').ZaloSocial;
var zsConfig = {
appId: '1131677296116040198',
redirectUri: 'http://localhost/login/zalo-callback',
secretkey: 'your app secret'
};
var ZSClient = new ZaloSocial(zsConfig);
Before call any API, you must have Access Token . You can get Access Token by Oauth Code and set value of access_token after you initialize ZaloSocial Instance , (access_token will be exipred in 3600s). Click Social API Document to see how to get Oauth Code for your App.
var code = 'Your oauth code';
ZSClient.getAccessTokenByOauthCode(code, function(response) {
if (response && response.access_token) {
ZSClient.setAccessToken(response.access_token);
}
});
Access User Information
ZSClient.api('me', 'GET', { fields: 'id, name, birthday, gender, picture' }, function(response) {
console.log(response);
});
Access Friends List
ZSClient.api('me/friends', function(response) {
console.log(response);
});
//Get list of your friends with offset and limit
ZSClient.api('me/friends', {offset: 10, limit: 50}, function(response) {
console.log(response);
});
//Get list of your friends who you can intvite to use your App.
ZSClient.api('me/invitable_friends', {offset: 10, limit: 50, fields: 'id, name, picture'}, function(response) {
console.log(response);
});
Post Feed
ZSClient.api('me/feed', 'POST', {message: 'Lorem ipsum dolor sit amet !', link: 'https://developers.zalo.me/'}, function(response) {
console.log(response);
});
Invite To Use The App
ZSClient.api('apprequests', 'POST', {to: '8549377444104328082', message: 'Lorem ipsum dolor sit amet !'}, function(response) {
console.log(response);
});
Send A Message To Friends
ZSClient.api('me/message', 'POST', {to: '8549377444104328082', message: 'Lorem ipsum dolor sit amet !', link: 'https://developers.zalo.me/'}, function(response) {
console.log(response);
});
Get Login Url
var loginUrl = ZSClient.getLoginUrl();
Format Login Url: https://oauth.zaloapp.com/v3/auth?app_id={1}&redirect_uri={2}
Login Flow
Provides a way for your application to access data on Zalo's platform. Through the HTTPS protocol, applications can interact with interested people on behalf of the Zalo Official Account.
To use the Official Account Open API you need to create an official account and register as 3rd party and follow the terms of Zalo.
Click to view Zalo Developer Documentation For Official Account Open API.
Create an instance of the ZaloOA class
var ZaloOA = require('zalo-sdk').ZaloOA;
var zaConfig = {
oaid: '2491302944280861639',
secretkey: 'your secret key'
}
var ZOAClient = new ZaloOA(zaConfig);
Get Profile Follower
var userId = 'user id or phone number';
ZOAClient.api('getprofile', { uid: userId }, function(response) {
console.log(response);
})
Send Text Message
var userId = 'user id';
ZOAClient.api('sendmessage/text', 'POST', {uid: userId, message: 'Zalo SDK Nodejs Test Message'}, function(response) {
console.log(response);
})
Get Message Status
ZOAClient.api('getmessagestatus', {msgid: 'fdb4c7ad668f37d16e9e'}, function(response) {
console.log(response);
})
Upload Image
var fileUrl = 'url of file you want to upload or absolute file path';
ZOAClient.api('upload/image','POST', {file: fileUrl}, function(response) {
console.log(response);
})
Upload Image Gif
var fileUrl = 'url of file you want to upload or absolute file path';
ZOAClient.api('upload/gif','POST', {file: fileUrl}, function(response) {
console.log(response);
})
Send Image Message
ZOAClient.api('sendmessage/image', 'POST', {uid: '', message: 'Zalo SDK Nodejs', 'imageid': ''}, function(response) {
console.log(response);
})
Send Gif Message
ZOAClient.api('sendmessage/gif', 'POST', {uid: '', width: '', height: '', 'imageid': ''}, function(response) {
console.log(response);
})
Send Link Message
var params = {
uid: '',
links: [{
link: 'https://developers.zalo.me/',
linktitle: 'Zalo For Developers',
linkdes: 'Document For Developers',
linkthumb: 'https://developers.zalo.me/web/static/prodution/images/bg.jpg'
}]
}
ZOAClient.api('sendmessage/links', 'POST', params, function(response) {
console.log(response);
})
Send Interactive Messages
var params = {
uid: '',
actionlist: [{
action: 'oa.open.inapp',
title: 'Send interactive messages',
description: 'This is a test for API send interactive messages',
thumb: 'https://developers.zalo.me/web/static/prodution/images/bg.jpg',
href: 'https://developers.zalo.me',
data: 'https://developers.zalo.me',
popup: {
title: 'Open Website Zalo For Developers',
desc: 'Click ok to visit Zalo For Developers and read more Document',
ok: 'ok',
cancel: 'cancel'
}
}]
}
ZOAClient.api('sendmessage/actionlist', 'POST', params, function(response) {
console.log(response);
})
Send A Message Customer Support To The Phone Number
var params = {
phone: '',
templateid: '',
templatedata: {}
}
ZOAClient.api('sendmessage/phone/cs', 'POST', params, function(response) {
console.log(response);
})
Send A Message Customer Support
var params = {
uid: '',
templateid: '',
templatedata: {}
}
ZOAClient.api('sendmessage/cs', 'POST', params, function(response) {
console.log(response);
})
Send Sticker
ZOAClient.api('sendmessage/sticker', 'POST', {uid: '', stickerid: ''}, function(response) {
console.log(response);
})
Reply Text Messages
ZOAClient.api('sendmessage/reply/text', 'POST', {msgid: '', message: ''}, function(response) {
console.log(response);
})
Reply Image Messages
ZOAClient.api('sendmessage/reply/image', 'POST', {msgid: '', imageid: '', message: ''}, function(response) {
console.log(response);
})
Reply Link Messages
ZOAClient.api('sendmessage/reply/links', 'POST', {msgid: '', links: ''}, function(response) {
console.log(response);
})
Create QR Code
ZOAClient.api('qrcode', 'POST', {qrdata: '', size: ''}, function(response) {
console.log(response);
})
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We will update more features in next version.
This project is licensed under the MIT License - see the LICENSE.md file for details
FAQs
NodeJS Library for Zalo
The npm package zalo-sdk receives a total of 13 weekly downloads. As such, zalo-sdk popularity was classified as not popular.
We found that zalo-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.