{"_id":"@cordova-ohos/cordova-plugin-weibosdk","_rev":"3-e2bdc95c87205293a35bec01edbb7523","name":"@cordova-ohos/cordova-plugin-weibosdk","dist-tags":{"latest":"0.6.5"},"versions":{"0.6.4":{"name":"@cordova-ohos/cordova-plugin-weibosdk","version":"0.6.4","keywords":["cordova","wechat","ecosystem:cordova","cordova-openharmony"],"author":{"name":"Huawei Device, Inc. Ltd. and","email":"马弓手"},"license":"Apache-2.0","_id":"@cordova-ohos/cordova-plugin-weibosdk@0.6.4","maintainers":[{"name":"luqi_tan","email":"295099422@qq.com"},{"name":"wanpengsz","email":"wanpengsz@163.com"},{"name":"xkh111","email":"xukaihui11@163.com"}],"bugs":{"url":"https://gitcode.com/OpenHarmony-Cordova/cordova-plugin-weibosdk/issues"},"dist":{"shasum":"c58ee788dbf4103168c52358f9ca8b018fc714f3","tarball":"https://registry.npmjs.org/@cordova-ohos/cordova-plugin-weibosdk/-/cordova-plugin-weibosdk-0.6.4.tgz","fileCount":9,"integrity":"sha512-GetK/f/zzOFjFAi9hyjQD2sbUeQGGX+koK1WxpKIruh0flaaU+y051NoyZ0gA0cpcTzPv00rgJ08fi7ZXJ3lfw==","signatures":[{"sig":"MEUCICiKHNDtpqPtFc6KA278sEtAnda8556QxygOeftnz3YjAiEAjCc6xAjzdUWpSlS9eQupw5y3SSwuZtgG0TDKIzDDGEs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":52538},"cordova":{"id":"cordova-plugin-weibosdk","platforms":["ohos"]},"engines":{"cordovaDependencies":{"0.6.4":{"hcordova":">=1.0.0","@cordova-ohos/ohos":">=2.0.0"}}},"gitHead":"84490293c1c1163be351b9fb7d7f6c1244cf05f7","_npmUser":{"name":"luqi_tan","email":"295099422@qq.com"},"repository":{"url":"gitcode:OpenHarmony-Cordova/cordova-plugin-weibosdk","type":"git"},"_npmVersion":"10.5.1","description":"Cordova Weibo Plugin","directories":{},"_nodeVersion":"22.0.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/cordova-plugin-weibosdk_0.6.4_1774228249652_0.972665779546682","host":"s3://npm-registry-packages-npm-production"}},"0.6.5":{"name":"@cordova-ohos/cordova-plugin-weibosdk","version":"0.6.5","description":"Cordova Weibo Plugin","cordova":{"id":"cordova-plugin-weibosdk","platforms":["ohos"]},"repository":{"type":"git","url":"gitcode:CPF-Cordova/cordova-plugin-weibosdk"},"bugs":{"url":"https://gitcode.com/CPF-Cordova/cordova-plugin-weibosdk/issues"},"keywords":["cordova","wechat","ecosystem:cordova","cordova-openharmony"],"engines":{"cordovaDependencies":{"0.6.5":{"@cordova-ohos/ohos":">=2.0.0","hcordova":">=1.0.0"}}},"author":{"name":"Huawei Device, Inc. Ltd. and","email":"马弓手"},"license":"Apache-2.0","_id":"@cordova-ohos/cordova-plugin-weibosdk@0.6.5","gitHead":"1d45d2b57132aeb9ac9c7ebf081da74984cdb0d3","_nodeVersion":"22.0.0","_npmVersion":"10.5.1","dist":{"integrity":"sha512-qDkuRxEzSUE6RgDyyzMr7HR3L4PYDgGzZ4K6e38wmd3QhROPQy15PiHEIwkmysozLupMrnaOH3Q4bA2bgQ/miQ==","shasum":"0ed8fa6c158f69925119bf7339b585badd723ad4","tarball":"https://registry.npmjs.org/@cordova-ohos/cordova-plugin-weibosdk/-/cordova-plugin-weibosdk-0.6.5.tgz","fileCount":10,"unpackedSize":71799,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDc9/beobG9nF2eAAORb0OJ7pNXSUZm3HzETmNcnCFF5wIgHcRqmr5LizMFZuw8/TyPShUIqcKH5r1HVx+kA11POpM="}]},"_npmUser":{"name":"luqi_tan","email":"295099422@qq.com"},"directories":{},"maintainers":[{"name":"luqi_tan","email":"295099422@qq.com"},{"name":"wanpengsz","email":"wanpengsz@163.com"},{"name":"xkh111","email":"xukaihui11@163.com"},{"name":"hcordova","email":"chenlihuiabc@163.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cordova-plugin-weibosdk_0.6.5_1785160456440_0.5153447031750225"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-23T01:10:49.491Z","modified":"2026-07-27T13:54:16.871Z","0.6.4":"2026-03-23T01:10:49.807Z","0.6.5":"2026-07-27T13:54:16.625Z"},"bugs":{"url":"https://gitcode.com/CPF-Cordova/cordova-plugin-weibosdk/issues"},"author":{"name":"Huawei Device, Inc. Ltd. and","email":"马弓手"},"license":"Apache-2.0","keywords":["cordova","wechat","ecosystem:cordova","cordova-openharmony"],"repository":{"type":"git","url":"gitcode:CPF-Cordova/cordova-plugin-weibosdk"},"description":"Cordova Weibo Plugin","maintainers":[{"name":"luqi_tan","email":"295099422@qq.com"},{"name":"wanpengsz","email":"wanpengsz@163.com"},{"name":"xkh111","email":"xukaihui11@163.com"},{"name":"hcordova","email":"chenlihuiabc@163.com"}],"readme":"# <center>cordova-plugin-weibosdk</center>\r\n\r\n[![zh-CN](https://img.shields.io/badge/lang-中文-blue.svg)](README.md)\r\n[![en](https://img.shields.io/badge/lang-English-blue.svg)](README.en.md)\r\n\r\n本项目基于 [cordova-plugin-weibosdk@0.6.4](https://npmjs.com/package/cordova-plugin-weibosdk/v/0.6.4) 开发，本文档重点阐述其在 OpenHarmony（OHOS）系统中的具体应用。\r\n\r\n- [cordova-plugin-weibosdk](#cordova-plugin-weibosdk)\r\n  - [简介](#简介)\r\n  - [支持平台](#支持平台)\r\n  - [下载安装](#下载安装)\r\n    - [前置准备](#前置准备)\r\n    - [从 npm 安装（推荐）](#从-npm-安装推荐)\r\n    - [从 GitCode 仓库安装](#从-gitcode-仓库安装)\r\n    - [离线安装（本地包）](#离线安装本地包)\r\n    - [安装后验证](#安装后验证)\r\n    - [卸载](#卸载)\r\n  - [约束与限制](#约束与限制)\r\n    - [兼容性](#兼容性)\r\n  - [使用示例](#使用示例)\r\n    - [1. 分享文本示例](#1-分享文本示例)\r\n    - [2. 分享图片示例](#2-分享图片示例)\r\n    - [3. 分享视频示例](#3-分享视频示例)\r\n  - [使用说明](#使用说明)\r\n    - [配置说明](#配置说明)\r\n      - [OHOS 额外配置](#ohos-额外配置)\r\n    - [配置参数（options）](#配置参数options)\r\n    - [API 说明](#api-说明)\r\n      - [1. 分享文本](#1-分享文本)\r\n      - [2. 分享图片](#2-分享图片)\r\n      - [3. 分享视频到微博](#3-分享视频到微博)\r\n  - [目录结构](#目录结构)\r\n  - [贡献代码](#贡献代码)\r\n  - [许可证](#许可证)\r\n  - [官方资源](#官方资源)\r\n\r\n\r\n## 简介\r\n\r\ncordova-plugin-weibosdk 是一款 Cordova/PhoneGap 插件，用于在混合应用（Hybrid App）中集成微博 SDK，支持微博分享核心功能，适配 OHOS 平台。\r\n\r\nOHOS 平台支持分享功能，具体参考 API 说明：\r\n\r\n1. 支持分享文本\r\n\r\n2. 支持分享沙箱图片，视频（不支持相册图片和视频直接分享）\r\n\r\n3. 支持在线图片（实际是插件下载后再分享）\r\n\r\n4. 在线视频（不建议直接分享在线视频，因在线视频插件下载后再分享，大视频速度较慢）\r\n\r\n## 支持平台\r\n\r\n- **OHOS**：5.0+\r\n\r\n## 下载安装\r\n\r\n### 前置准备\r\n\r\n1. 注册 [微博开放平台](https://open.weibo.com/) 账号，创建移动应用\r\n\r\n2. 完善应用信息：\r\n    - OHOS：填写应用包名，上传签名文件等信息（当前开发平台不支持 OHOS 平台资料填写，请把信息填写在 Android 中）\r\n\r\n3. 签名信息获取\r\n    - 方法一：在微博开发平台下载 OHOS SDK，下载后设置签名，签名信息可以填写真实应用的信息，运行 SDK Demo，可以在日志中获取签名信息\r\n    - 方法二：在您的应用中，集成 OHOS SDK 的 core.har 包，然后根据 Demo 代码在您的应用中获取签名\r\n\r\n### 从 npm 安装（推荐）\r\n\r\n```bash\r\n# 安装 hcordova\r\nnpm install -g hcordova\r\n\r\n# 全平台安装插件\r\nhcordova plugin add cordova-plugin-weibosdk\r\n\r\n# 指定 OHOS 平台安装\r\nhcordova plugin add cordova-plugin-weibosdk --platform ohos\r\n\r\n# 指定版本安装\r\nhcordova plugin add cordova-plugin-weibosdk@0.6.4 --platform ohos\r\n```\r\n\r\n### 从 GitCode 仓库安装\r\n\r\n```bash\r\n# 仅安装到 OHOS 平台\r\n# 默认分支安装\r\nhcordova plugin add https://gitcode.com/CPF-Cordova/cordova-plugin-weibosdk.git --platform ohos\r\n\r\n# 指定标签/分支安装\r\nhcordova plugin add https://gitcode.com/CPF-Cordova/cordova-plugin-weibosdk.git@develop --platform ohos\r\n```\r\n\r\n### 离线安装（本地包）\r\n\r\n适用于无网络环境，先下载插件包到本地，再执行离线安装：\r\n\r\n```bash\r\n# 下载插件包到本地（示例路径：~/Downloads/cordova-plugin-weibosdk）\r\n# 执行离线安装\r\nhcordova plugin add ~/Downloads/cordova-plugin-weibosdk --platform ohos\r\n```\r\n\r\n### 安装后验证\r\n\r\n安装完成后，可通过以下命令验证插件是否成功添加到项目中：\r\n\r\n```bash\r\n# 查看已安装的插件列表，若包含本插件 ID 则表示插件已成功安装\r\nhcordova plugin list\r\n```\r\n\r\n### 卸载\r\n\r\n```bash\r\n# Cordova CLI 全平台卸载\r\nhcordova plugin remove cordova-plugin-weibosdk \r\n\r\n# 指定平台卸载\r\nhcordova plugin remove cordova-plugin-weibosdk --platform ohos\r\n```\r\n\r\n## 约束与限制\r\n### 兼容性\r\n\r\n支持：\r\n\r\n| 项目 | 版本/信息 |\r\n|-----|--------|\r\n| SDK | API12+ |\r\n| IDE | DevEco Studio: 5.0+ |\r\n| ROM | 5.1+ |\r\n| Emulator | OpenHarmony 6.0+ |\r\n\r\n在以下版本中已测试通过：\r\n\r\n| 项目 | 版本/信息 |\r\n|-----|--------|\r\n| @cordova-ohos/ohos | 14.0.1-ohos-14.0.1 |\r\n| SDK | 5.0.0(12) |\r\n| IDE | DevEco Studio: 6.0.13.200 |\r\n| ROM | 5.1.0.120 SP3 |\r\n| Emulator | OpenHarmony 6.0.1(21) |\r\n\r\n## 使用示例\r\n\r\n### 1. 分享文本示例\r\n\r\n```javascript\r\n// 使用示例\r\n var args = {};\r\nargs.text = 'This is a Cordova Plugin';\r\nWeiboSDK.shareTextToWeibo(function () {\r\n    document.getElementById(\"weiboShareText\").innerHTML = \"分享成功\";\r\n}, function (failReason) {\r\n    document.getElementById(\"weiboShareText\").innerHTML = \"分享失败：\"+failReason;\r\n}, args);\r\n```\r\n\r\n### 2. 分享图片示例\r\n\r\n```javascript\r\n// 从相册选择一个图片分享到微博\r\nvar options = {\r\n    // Some common settings are 20, 50, and 100\r\n    quality: 80,\r\n    destinationType: Camera.DestinationType.DATA_URL,\r\n    // In this app, dynamically set the picture source, Camera or photo gallery\r\n    sourceType: Camera.PictureSourceType.PHOTOLIBRARY,\r\n    encodingType: Camera.EncodingType.JPEG,\r\n    mediaType: Camera.MediaType.PICTURE,\r\n    targetWidth:800,\r\n    targetHeight:600,\r\n    allowEdit: true,\r\n    correctOrientation: true  // Corrects Android orientation quirks\r\n}\r\nnavigator.camera.getPicture(function cameraSuccess(imageData) {\r\n    var args = {};\r\n    args.image = \"data:image/jpeg;base64,\"+imageData;\r\n    WeiboSDK.shareImageToWeibo(function () {\r\n        document.getElementById(\"weiboShareImageUrl\").innerHTML = \"分享成功\";\r\n    }, function (failReason) {\r\n        document.getElementById(\"weiboShareImageUrl\").innerHTML = \"分享失败：\"+failReason;\r\n    }, args);\r\n}, function cameraError(error) {\r\n    console.debug(\"Unable to obtain picture: \" + error, \"app\");\r\n}, options);\r\n```\r\n\r\n```javascript\r\n// 分享在线图片到微博\r\nvar args = {};\r\nargs.image = 'https://res-static.hc-cdn.cn/cloudbu-site/china/zh-cn/hdhomeportal/logonew.png';\r\nWeiboSDK.shareImageToWeibo(function () {\r\n    document.getElementById(\"weiboShareImageUrl\").innerHTML = \"分享成功\";\r\n}, function (failReason) {\r\n    document.getElementById(\"weiboShareImageUrl\").innerHTML = \"分享失败：\"+failReason;\r\n}, args);\r\n```\r\n\r\n### 3. 分享视频示例\r\n\r\n```javascript\r\n// 从相册选择一个封面图片，从网络下载一个视频分享（生产环境，不建议下载视频分享）\r\nvar options = {\r\n    // Some common settings are 20, 50, and 100\r\n    quality: 80,\r\n    destinationType: Camera.DestinationType.FILE_URI,\r\n    // In this app, dynamically set the picture source, Camera or photo gallery\r\n    sourceType: Camera.PictureSourceType.PHOTOLIBRARY,\r\n    encodingType: Camera.EncodingType.JPEG,\r\n    mediaType: Camera.MediaType.PICTURE,\r\n    allowEdit: true,\r\n    cameraDirection:Camera.Direction.FRONT,\r\n    correctOrientation: true  // Corrects Android orientation quirks\r\n}\r\nnavigator.camera.getPicture(function cameraSuccess(imageUri) {\r\n    var args = {};\r\n    args.image = imageUri;\r\n    args.videoUrl = \"https://vod.chuzhitong.com/Act-ss-mp4-hd/SVID_20250928_140357_1.mp4\";\r\n    WeiboSDK.shareToWeibo(function () {\r\n        document.getElementById(\"weiboShareImageUrl\").innerHTML = \"分享成功\";\r\n    }, function (failReason) {\r\n        document.getElementById(\"weiboShareImageUrl\").innerHTML = \"分享失败：\"+failReason;\r\n    }, args);\r\n}, function cameraError(error) {\r\n    console.debug(\"Unable to obtain picture: \" + error, \"app\");\r\n}, options);\r\n```\r\n\r\n## 使用说明\r\n\r\n### 配置说明\r\n\r\n#### OHOS 额外配置\r\n\r\n1. 复制微博 SDK 的 Demo 工程的 lib/core.har 到您的功能对应的目录\r\n\r\n2. 在主工程 oh-package.json5 中添加 core（core 是微博的 har 包，这个命名实在很糟糕，以致于会有很多的异议）的依赖。\r\n   \r\n```json\r\n{\r\n  \"name\": \"entry\",\r\n  \"version\": \"1.0.0\",\r\n  \"description\": \"Please describe the basic information.\",\r\n  \"main\": \"\",\r\n  \"author\": \"\",\r\n  \"license\": \"\",\r\n  \"dependencies\": {\r\n    \"@cordova-ohos/ohos\": \"file:../cordova\",\r\n    \"core\": \"file:./lib/core.har\"\r\n  }\r\n}\r\n```\r\n\r\n3. 在主工程中，执行 ohpm entry/lib/core.har 安装 weiboSDK\r\n\r\n4. 修改项目中的 EntryAbility 的代码，添加微博插件在 ArkTS 侧监听和初始化：\r\n\r\n```typescript\r\nexport default class EntryAbility extends UIAbility {\r\n   onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {\r\n      // 添加如下代码，初始化微博 SDK\r\n        weiboArgs[\"APP_KEY\"] = \"YOUR_APP_KEY\"; // 开发平台获取\r\n        weiboArgs[\"REDIRECT_URL\"] = \"YOUR_REDIRECT_URL\"; // 回调 URL，主要用于授权登录，但是当前授权登录，OHOS 微博 SDK 并未真正实现，因此该 URL 作用不大，但是必须配置\r\n        weiboArgs[\"SCOPE\"] = \"email,direct_messages_read,direct_messages_write,friendships_groups_read,friendships_groups_write,statuses_to_me_read,follow_app_official_microblog,invitation_write\";\r\n        PluginRegisterHandle(this, want, \"WeiboAction/WeiboAction\", \"EntryAbility\", JSON.stringify(weiboArgs));\r\n   }\r\n}\r\n```\r\n\r\n5. 在主工程中添加 core（注意 core 是微博的 har 包，这是一个微博 SDK 糟糕的命名）为动态导入，如下：\r\n\r\n```json\r\n\"runtimeOnly\": {\r\n\"packages\": [\r\n    \"core\"\r\n]\r\n}\r\n```\r\n\r\n### 配置参数（options）\r\n\r\n| 参数 | 类型 | 说明 |\r\n|---|---|---|\r\n| text | string | 分享的文本 |\r\n| image | string | 分享的图片，可以是 url，base64，沙箱路径 |\r\n| videoUrl | string | 分享的视频，可以沙箱路径，url（不建议直接使用 url） |\r\n\r\n### API 说明\r\n\r\n#### 1. 分享文本\r\n\r\n```javascript\r\n/*\r\n* success 成功分享函数\r\n* failed 分享失败函数\r\n*/\r\nWeiboSDK.shareTextToWeibo(success, failed, options);\r\n```\r\n\r\n#### 2. 分享图片\r\n\r\n```javascript\r\n/*\r\n* success 成功分享函数\r\n* failed 分享失败函数\r\n*/\r\nWeiboSDK.shareImageToWeibo(success, failed, options);\r\n```\r\n\r\n#### 3. 分享视频到微博\r\n\r\n```javascript\r\n/*\r\n* success 成功分享函数\r\n* failed 分享失败函数\r\n*/\r\nWeiboSDK.shareToWeibo(success, failed, options);\r\n```\r\n\r\n## 目录结构\r\n\r\n```\r\ncordova-plugin-weibosdk              # [根目录] 新浪微博 SDK 插件项目根目录\r\n├── src                              # [源码目录] 存放原生平台代码\r\n│   └── main                         # [主目录] 主代码目录\r\n│       ├── cpp                      # [C++ 目录] C++ 原生代码目录\r\n│       │   └── Weibo                # [C++ 模块] 微博功能 C++ 模块文件夹\r\n│       │       ├── WeiboSDKPlugin.cpp # [C++ 实现] C++ 源文件，实现微博登录/分享等核心逻辑\r\n│       │       └── WeiboSDKPlugin.h   # [C++ 声明] C++ 头文件，定义微博功能接口\r\n│       └── ets                      # [ArkTS 目录] ArkTS/ETS 代码目录\r\n│           └── components           # [组件目录] 存放 UI 组件\r\n│               └── WeiboAction      # [TS 模块] 微博相关操作 UI 组件文件夹\r\n│                   └── WeiboAction.ets # [ETS 文件] 微博操作相关的 UI 组件（如授权界面、分享面板）\r\n├── www                              # [前端目录] 存放供 Web 端调用的 JS 接口文件\r\n│   └── weibo.js                     # [JS 文件] 暴露给 Web 端的 JS 接口，用于调用微博功能\r\n├── .gitignore                       # [配置] Git 版本控制忽略文件配置\r\n├── LICENSE                          # [文本] 开源许可证文件\r\n├── OAT.xml                          # [配置] 门禁配置文件\r\n├── package.json                     # [配置] 项目元数据及依赖配置文件\r\n├── plugin.xml                       # [配置] Cordova 插件核心配置文件\r\n└── README.md                        # [文档] 项目说明文档\r\n```\r\n\r\n## 贡献代码\r\n\r\n使用过程中发现任何问题都可以提 [Issue](https://gitcode.com/CPF-Cordova/cordova-plugin-weibosdk/issues) ，当然也非常欢迎发 [PR](https://gitcode.com/CPF-Cordova/cordova-plugin-weibosdk/pulls) 共建。\r\n\r\n## 许可证\r\n\r\n本插件基于 **Apache License 2.0** 开源，详见 [LICENSE](LICENSE) 文件。\r\n\r\n## 官方资源\r\n\r\n- Android 和 iOS：[cordova-plugin-weibosdk 官方指南](https://www.npmjs.com/package/cordova-plugin-weibosdk)\r\n\r\n- GitCode 仓库：[CPF-Cordova/cordova-plugin-weibosdk](https://gitcode.com/CPF-Cordova/cordova-plugin-weibosdk)\r\n","readmeFilename":"README.md"}