[Version 1.0.0 Interface 2015-1-9]
[Organized on 2015-6-17]
Official DEMO (Use WeChat Scan to open QR code test)
[caption id="attachment_699" align="alignnone" width="250"]
WeChat API[/caption]
I. New APIs
1. Interface Detection
Detects WeChat version's support for JS interfaces, but can only detect new interfaces (interfaces released after version 6.0.2)
jssdk is compatible with lower versions, no need for third parties to do extra work, but some interfaces are newly introduced in 6.0.2, only new versions can call them
2. Audio
new: 1) Start/Stop recording [Requires binding official account] 2) Play/Pause/Stop audio 3) Upload/Download audio
highlight: 4) Recognize audio, return JSON data
Officially recommended for official account services, such as order inquiry (user inputs a voice, the interface parses audio to get keyword information, third-party service queries order based on keywords and returns results)
Recognition speed is relatively slow, in wifi environment, 2-4 character audio returns results in 4-8 seconds, accuracy rate is not very high
notice: User recordings will be uploaded to WeChat servers, third parties need to download themselves, format is amr, for transcoding please see: http://segmentfault.com/q/1010000002506317/a-1020000002513789
[Audio API is for recording, not all audio]
code:
wx.playVoice({
localId: '' // Local ID of audio to play, obtained from stopRecord interface
});
3. Cards/Coupons
new: 1) Batch add cards 2) View cards in card package
notice: Only provides services for official accounts, Weidian stores, cards are generally used for membership cards (similar to Dianping), coupons
[Official account WeChat activities may need this, requires backend service cooperation to implement card distribution mechanism]
For example: Share with friends to collect cards, get rewards when complete
4. Shake to Follow
Provides services for official accounts, shake around peripheral over 500 official accounts automatically activate interface permissions, can only be used in [WeChat Shake Around]
II. Enhanced Old APIs
1. Sharing
old: Tencent Weibo, Facebook
new: 1) Share to Moments 2) Share to Friends 3) Share to QQ
[Requires binding official account, and requires verification]
code:
// onMenuShareTimeline Moments
// onMenuShareAppMessage Friends
// onMenuShareQQ QQ
// onMenuShareWeibo Tencent Weibo
wx.onMenuShareTimeline({
title: '', // Share title
link: '', // Share link
imgUrl: '', // Share icon
success: function () {
// Callback function executed after user confirms sharing
},
cancel: function () {
// Callback function executed after user cancels sharing
}
});
2. Images
old: Image preview
new: 1) Take photo/Select from album [Requires binding official account] 2) Upload/Download [Need to call 1) first, currently only supports uploading one image at a time]
notice: Image preview supports zooming, and doesn't require binding official account
3. Device Information
old: Network status, Get geographic location [Requires user confirmation]
new: 1) Open using WeChat built-in map (Tencent Map)
4. UI
old: Hide top-right button, Hide bottom navigation bar, Close current webpage window interface
new: (Hide/Show top-right menu interface), Batch hide/show function button interfaces, Hide non-basic functions, Show all functions
5. QR Code
old: [x] Scan QR code
new: scanQRCode (directly return results) and scanQRCode (WeChat processes results)
6. WeChat Pay
old: Initiate official account WeChat payment
new: Initiate a WeChat payment request
notice: [Requires binding official account, divided into card swiping payment/QR code payment/official account payment/app payment]
III. Still Available Old Special Interfaces
Send email
IV. Video
WeChat has not yet opened video capabilities, small videos in Moments are natively implemented. On Android 4.0+ phones, after installing QQ Browser, video playback in WeChat webpages can be optimized by X5 engine. Currently using HTML5 standard video will encounter performance issues on low-end phones.
V. Old APIs
Image preview
View profile
Share Weibo [access_denied]
Share Facebook [x]
Add contact [fail_invalid_appid]
Scan QR code [x]
Jump to designated official account page [Insufficient permissions]
Hide top-right button
Hide bottom navigation bar [x, no navigation bar at bottom]
Get network status
Close
Initiate official account WeChat payment [fail_invalid_appid]
Set page status [x]
Send email
WeChat team opens webView, jumps to designated page [access_denied]
getCanIAPPay [function_not_exist]
Initiate official account IAP payment [function_not_exist]
Open designated link with safari [x]
Jump to WeChat product page [access_denied]
View geographic location [access_denied]
Moments check-in [access_denied]
Activate WeChat credit card [fail_invalid_appid]
Get geographic location [fail]
Get whether an app is installed [access_denied]
Official account edit shipping address [fail]
Official account get nearest shipping address [fail]
Launch third-party APP [fail_invalid_appid]
Jump to WeChat product purchase interface [access_denied]
Add emoji [access_denied]
Cancel downloading an emoji [access_denied]
Query whether an emoji exists [access_denied]
VI. New APIs
[Version 1.0.0 Interface 2015-1-9]
Basic Interfaces
Check if current client supports designated JS interface, checkJsApi
Sharing Interfaces
Get "Share to Moments" button click status and custom share content interface, onMenuShareTimeline
Get "Share to Friends" button click status and custom share content interface, onMenuShareAppMessage
Get "Share to QQ" button click status and custom share content interface, onMenuShareQQ
Get "Share to Tencent Weibo" button click status and custom share content interface, onMenuShareWeibo
Image Interfaces
Take photo or select from phone album interface, chooseImage
Preview image interface, previewImage
Upload image interface, uploadImage
Download image interface, downloadImage
Audio Interfaces
Start recording interface, startRecord
Stop recording interface, stopRecord
Play voice interface, playVoice
Pause playback interface, pauseVoice
Stop playback interface, stopVoice
Upload voice interface, uploadVoice
Download voice interface, downloadVoice
Smart Interfaces
Recognize audio and return recognition result interface, translateVoice
Device Information Interfaces
Get network status interface, getNetworkType
Geographic Location Interfaces
Use WeChat built-in map to view location interface, openLocation
Get geographic location interface, getLocation
UI Operation Interfaces
Hide top-right menu interface, hideOptionMenu
Show top-right menu interface, showOptionMenu
Close current webpage window interface, closeWindow
Batch hide function button interface, hideMenuItems
Batch show function button interface, showMenuItems
Hide all non-basic button interface, hideAllNonBaseMenuItem
Show all function button interface, showAllNonBaseMenuItem
WeChat Scan
Invoke WeChat Scan interface, scanQRCode (WeChat processes results)/scanQRCode (directly return results)
WeChat Store Interfaces
Jump to WeChat product page interface, openProductSpecificView
WeChat Card/Coupon Interfaces
Batch add cards interface, addCard
Invoke card list suitable for stores and get user selection list, chooseCard
View cards in WeChat card package interface, openCard
WeChat Payment Interfaces
Initiate a WeChat payment request, chooseWXPay
No comments yet. Be the first to share your thoughts.