mirror of
https://github.com/RxReader/tencent_kit.git
synced 2025-05-20 16:56:33 +08:00
整理
This commit is contained in:
@ -1,3 +1,7 @@
|
||||
## 3.0.0
|
||||
|
||||
* 重构
|
||||
|
||||
## 2.1.1
|
||||
|
||||
* 升级SDK
|
||||
|
@ -121,6 +121,7 @@ Capabilities -> Associated Domain -> Domain -> applinks:${your applinks}
|
||||
|QZone|支持|不支持|不支持|不支持|不支持|支持|
|
||||
|
||||
* break change
|
||||
* 3.0.0: 重构
|
||||
* 2.1.0: nullsafety & 不再支持 Android embedding v1 & Tencent 单例
|
||||
|
||||
* snapshot
|
||||
|
@ -1,5 +1,5 @@
|
||||
group 'io.github.v7lin.tencent_kit'
|
||||
version '2.1.1'
|
||||
version '3.0.0'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
|
@ -8,10 +8,10 @@ PODS:
|
||||
- sqflite (0.0.2):
|
||||
- Flutter
|
||||
- FMDB (>= 2.7.5)
|
||||
- tencent_kit (2.1.1):
|
||||
- tencent_kit (3.0.0):
|
||||
- Flutter
|
||||
- tencent_kit/vendor (= 2.1.1)
|
||||
- tencent_kit/vendor (2.1.1):
|
||||
- tencent_kit/vendor (= 3.0.0)
|
||||
- tencent_kit/vendor (3.0.0):
|
||||
- Flutter
|
||||
|
||||
DEPENDENCIES:
|
||||
@ -39,7 +39,7 @@ SPEC CHECKSUMS:
|
||||
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
|
||||
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
|
||||
sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904
|
||||
tencent_kit: 72c1dbfff5c84fd6e68363dfe6208a36235ef3be
|
||||
tencent_kit: 01deba7fcb491409961447556cafeab420a0c8ea
|
||||
|
||||
PODFILE CHECKSUM: 8e679eca47255a8ca8067c4c67aab20e64cb974d
|
||||
|
||||
|
@ -4,6 +4,9 @@ import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||
import 'package:tencent_kit/tencent_kit.dart';
|
||||
import 'package:tencent_kit_example/model/api/tencent_user_info_resp.dart';
|
||||
import 'package:tencent_kit_example/model/unionid/tencent_unionid_resp.dart';
|
||||
import 'package:tencent_kit_example/tencent.dart';
|
||||
|
||||
const String _TENCENT_APPID = 'your tencent appId';
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:tencent_kit/src/model/api/tencent_api_resp.dart';
|
||||
import 'package:tencent_kit_example/model/api/tencent_api_resp.dart';
|
||||
|
||||
part 'tencent_user_info_resp.g.dart';
|
||||
|
69
example/lib/tencent.dart
Normal file
69
example/lib/tencent.dart
Normal file
@ -0,0 +1,69 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:tencent_kit/tencent_kit.dart';
|
||||
import 'package:tencent_kit_example/model/api/tencent_user_info_resp.dart';
|
||||
import 'package:tencent_kit_example/model/unionid/tencent_unionid_resp.dart';
|
||||
|
||||
extension MixerTencent on Tencent {
|
||||
|
||||
/// 用户信息
|
||||
/// https://wiki.connect.qq.com/get_user_info
|
||||
Future<TencentUserInfoResp> getUserInfo({
|
||||
required String appId,
|
||||
required String openid,
|
||||
required String accessToken,
|
||||
}) {
|
||||
return HttpClient()
|
||||
.getUrl(Uri.parse(
|
||||
'https://graph.qq.com/user/get_user_info?access_token=$accessToken&oauth_consumer_key=$appId&openid=$openid'))
|
||||
.then((HttpClientRequest request) {
|
||||
return request.close();
|
||||
}).then((HttpClientResponse response) async {
|
||||
if (response.statusCode == HttpStatus.ok) {
|
||||
final ContentType? contentType = response.headers.contentType;
|
||||
final Encoding encoding =
|
||||
Encoding.getByName(contentType?.charset) ?? utf8;
|
||||
final String content = await encoding.decodeStream(response);
|
||||
return TencentUserInfoResp.fromJson(
|
||||
json.decode(content) as Map<String, dynamic>);
|
||||
}
|
||||
throw HttpException(
|
||||
'HttpResponse statusCode: ${response.statusCode}, reasonPhrase: ${response.reasonPhrase}.');
|
||||
});
|
||||
}
|
||||
|
||||
/// UnionID
|
||||
/// https://wiki.connect.qq.com/unionid%E4%BB%8B%E7%BB%8D
|
||||
Future<TencentUnionidResp> getUnionId({
|
||||
required String accessToken,
|
||||
String unionid = '1',
|
||||
}) {
|
||||
return HttpClient()
|
||||
.getUrl(Uri.parse(
|
||||
'https://graph.qq.com/oauth2.0/me?access_token=$accessToken&unionid=$unionid'))
|
||||
.then((HttpClientRequest request) {
|
||||
return request.close();
|
||||
}).then((HttpClientResponse response) async {
|
||||
if (response.statusCode == HttpStatus.ok) {
|
||||
final ContentType? contentType = response.headers.contentType;
|
||||
final Encoding encoding =
|
||||
Encoding.getByName(contentType?.charset) ?? utf8;
|
||||
final String callback = await encoding.decodeStream(response);
|
||||
// 腾讯有毒 callback( $json );
|
||||
final RegExp exp = RegExp(r'callback\( (.*) \)\;');
|
||||
final Match? match = exp.firstMatch(callback);
|
||||
if (match?.groupCount == 1) {
|
||||
final String? content = match!.group(1);
|
||||
if (content != null) {
|
||||
return TencentUnionidResp.fromJson(
|
||||
json.decode(content) as Map<String, dynamic>);
|
||||
}
|
||||
}
|
||||
}
|
||||
throw HttpException(
|
||||
'HttpResponse statusCode: ${response.statusCode}, reasonPhrase: ${response.reasonPhrase}.');
|
||||
});
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
#
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'tencent_kit'
|
||||
s.version = '2.1.1'
|
||||
s.version = '3.0.0'
|
||||
s.summary = 'A powerful Flutter plugin allowing developers to auth/share with natvie Android & iOS Tencent SDKs.'
|
||||
s.description = <<-DESC
|
||||
A powerful Flutter plugin allowing developers to auth/share with natvie Android & iOS Tencent SDKs.
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:tencent_kit/src/model/sdk/tencent_sdk_resp.dart';
|
||||
import 'package:tencent_kit/src/model/tencent_sdk_resp.dart';
|
||||
|
||||
part 'tencent_login_resp.g.dart';
|
||||
|
@ -1,12 +1,8 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:tencent_kit/src/model/api/tencent_user_info_resp.dart';
|
||||
import 'package:tencent_kit/src/model/sdk/tencent_login_resp.dart';
|
||||
import 'package:tencent_kit/src/model/sdk/tencent_sdk_resp.dart';
|
||||
import 'package:tencent_kit/src/model/unionid/tencent_unionid_resp.dart';
|
||||
import 'package:tencent_kit/src/model/tencent_login_resp.dart';
|
||||
import 'package:tencent_kit/src/model/tencent_sdk_resp.dart';
|
||||
import 'package:tencent_kit/src/tencent_constant.dart';
|
||||
|
||||
///
|
||||
@ -123,65 +119,6 @@ class Tencent {
|
||||
return _channel.invokeMethod<void>(_METHOD_LOGOUT);
|
||||
}
|
||||
|
||||
/// 用户信息
|
||||
/// https://wiki.connect.qq.com/get_user_info
|
||||
Future<TencentUserInfoResp> getUserInfo({
|
||||
required String appId,
|
||||
required String openid,
|
||||
required String accessToken,
|
||||
}) {
|
||||
return HttpClient()
|
||||
.getUrl(Uri.parse(
|
||||
'https://graph.qq.com/user/get_user_info?access_token=$accessToken&oauth_consumer_key=$appId&openid=$openid'))
|
||||
.then((HttpClientRequest request) {
|
||||
return request.close();
|
||||
}).then((HttpClientResponse response) async {
|
||||
if (response.statusCode == HttpStatus.ok) {
|
||||
final ContentType? contentType = response.headers.contentType;
|
||||
final Encoding encoding =
|
||||
Encoding.getByName(contentType?.charset) ?? utf8;
|
||||
final String content = await encoding.decodeStream(response);
|
||||
return TencentUserInfoResp.fromJson(
|
||||
json.decode(content) as Map<String, dynamic>);
|
||||
}
|
||||
throw HttpException(
|
||||
'HttpResponse statusCode: ${response.statusCode}, reasonPhrase: ${response.reasonPhrase}.');
|
||||
});
|
||||
}
|
||||
|
||||
/// UnionID
|
||||
/// https://wiki.connect.qq.com/unionid%E4%BB%8B%E7%BB%8D
|
||||
Future<TencentUnionidResp> getUnionId({
|
||||
required String accessToken,
|
||||
String unionid = '1',
|
||||
}) {
|
||||
return HttpClient()
|
||||
.getUrl(Uri.parse(
|
||||
'https://graph.qq.com/oauth2.0/me?access_token=$accessToken&unionid=$unionid'))
|
||||
.then((HttpClientRequest request) {
|
||||
return request.close();
|
||||
}).then((HttpClientResponse response) async {
|
||||
if (response.statusCode == HttpStatus.ok) {
|
||||
final ContentType? contentType = response.headers.contentType;
|
||||
final Encoding encoding =
|
||||
Encoding.getByName(contentType?.charset) ?? utf8;
|
||||
final String callback = await encoding.decodeStream(response);
|
||||
// 腾讯有毒 callback( $json );
|
||||
final RegExp exp = RegExp(r'callback\( (.*) \)\;');
|
||||
final Match? match = exp.firstMatch(callback);
|
||||
if (match?.groupCount == 1) {
|
||||
final String? content = match!.group(1);
|
||||
if (content != null) {
|
||||
return TencentUnionidResp.fromJson(
|
||||
json.decode(content) as Map<String, dynamic>);
|
||||
}
|
||||
}
|
||||
}
|
||||
throw HttpException(
|
||||
'HttpResponse statusCode: ${response.statusCode}, reasonPhrase: ${response.reasonPhrase}.');
|
||||
});
|
||||
}
|
||||
|
||||
/// 分享 - 说说
|
||||
Future<void> shareMood({
|
||||
required int scene,
|
||||
|
@ -1,9 +1,6 @@
|
||||
library tencent_kit;
|
||||
|
||||
export 'src/model/api/tencent_api_resp.dart';
|
||||
export 'src/model/api/tencent_user_info_resp.dart';
|
||||
export 'src/model/sdk/tencent_login_resp.dart';
|
||||
export 'src/model/sdk/tencent_sdk_resp.dart';
|
||||
export 'src/model/unionid/tencent_unionid_resp.dart';
|
||||
export 'src/model/tencent_login_resp.dart';
|
||||
export 'src/model/tencent_sdk_resp.dart';
|
||||
export 'src/tencent.dart';
|
||||
export 'src/tencent_constant.dart';
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: tencent_kit
|
||||
description: A powerful Flutter plugin allowing developers to auth/share with natvie Android & iOS Tencent SDKs.
|
||||
version: 2.1.1
|
||||
version: 3.0.0
|
||||
# author: v7lin <v7lin@qq.com>
|
||||
homepage: https://github.com/v7lin/fake_tencent
|
||||
|
||||
|
Reference in New Issue
Block a user