本文将为您提供关于关于jfinalweixin多公众号的支持的详细介绍,我们还将为您解释公众号接入多平台的相关知识,同时,我们还将为您提供关于cURLerror6:Couldnotresolve:ap
本文将为您提供关于关于jfinal weixin 多公众号的支持的详细介绍,我们还将为您解释公众号接入多平台的相关知识,同时,我们还将为您提供关于cURL error 6: Could not resolve: api.weixin.qq.com (Could not contact DNS servers)、iOS实战:第三方登陆weibo/weixin/qq集成、Jfinal weixin maven id、Jfinal weixin 源码分析 --- 碎碎念(看最后,有福利)的实用信息。
本文目录一览:- 关于jfinal weixin 多公众号的支持(公众号接入多平台)
- cURL error 6: Could not resolve: api.weixin.qq.com (Could not contact DNS servers)
- iOS实战:第三方登陆weibo/weixin/qq集成
- Jfinal weixin maven id
- Jfinal weixin 源码分析 --- 碎碎念(看最后,有福利)
关于jfinal weixin 多公众号的支持(公众号接入多平台)
@JFinal 你好,想跟你请教个问题:
首先非常感谢jfinal,让我节省了很多开发时间,代码简洁优美,值得学习。
jfinal weixin sdk写的非常不错,但运行demo发现 只能支持一个公众号,而且也没有入库操作。
能否升级下demo,或提供实现思路,支持多公众号并把信息都存入数据库,这样才更实用一些。
希望詹总考虑下。
cURL error 6: Could not resolve: api.weixin.qq.com (Could not contact DNS servers)
“api.weixin.qq.com” 定位是否微信服务器问题,一般不太可能。
1. 首先呢,我们根据出现的问题对问题的故障进行排查,由于后端使用 curl 进行连接的,所以我们首先要保证我们的 curl 连接是正常的,需要测试一下 curl 是否能够正常解析 dns,使用如下命令进行测试工作:
curl api.weixin.qq.com
最终测试结果为 ping 不通!继而我们开始执行对应新的解决方案。
2.ping 不通一般情况下属于 DNS 配置相关的问题,所以我们开始进行编辑修改 DNS 配置文件:
vi /etc/resolv.conf
在源文件的内容基础之下,添加如下两行代码:
nameserver 114.114.114.114
nameserver 8.8.8.8
iOS实战:第三方登陆weibo/weixin/qq集成
一、前篇:去各个官网找相应sdk和教程
Weixin官方iOS接入指南和代码实例下载
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=1417694084&token=&lang=zh_CN
qq文档
http://wiki.open.qq.com/wiki/API3.0%E6%96%87%E6%A1%A3#.E5.85.AC.E5.85.B1.E5.8F.82.E6.95.B0.E8.AF.B4.E6.98.8E
http://wiki.open.qq.com/wiki/%E8%85%BE%E8%AE%AF%E5%BC%80%E6%94%BE%E5%B9%B3%E5%8F%B0%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E7%AD%BE%E5%90%8D%E5%8F%82%E6%95%B0sig%E7%9A%84%E8%AF%B4%E6%98%8E
weibo
http://open.weibo.com/wiki/2/users/show
2.分析
大概都分3步,发送请求并回调,回调中处理返回结果,根据返回结果再去请求下一步。
3.info.plist里配置对应URL types
4.代码
AppDelegate.h
#import "WXApi.h"
#import "WeiboSDK.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate, WXApiDelegate,WeiboSDKDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
AppDelegate.m
#pragma mark - Init PlatValue
- (void)initializeSharePlat
{
//注册初始化参数
//weibo
[WeiboSDK enableDebugMode:YES];
[WeiboSDK registerApp:kWeiboAppKey];
//weixin
[WXApi registerApp:kWeiXinAppKey];
//qq也可以不在这里初始化,直接在需要的页面中初始化,本项目暂只用于登陆,在这可以不初始化
// TencentOAuth * _oauth = [[TencentOAuth alloc] initWithAppId:kTencentAppKey andDelegate:self];
}
#pragma mark -
#pragma mark openURL
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{ return [WeiboSDK handleOpenURL:url delegate:self] || [WXApi handleOpenURL:url delegate:self] || [TencentOAuth HandleOpenURL:url];
}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{ return [WeiboSDK handleOpenURL:url delegate:self] || [WXApi handleOpenURL:url delegate:self] || [TencentOAuth HandleOpenURL:url];
}
#pragma mark - Weixin
- (void)onReq:(BaseReq *)req
{
NSLog(@"onReq: %@", req);
//onReq是微信终端向第三方程序发起请求,要求第三方程序响应。第三方程序响应完后必须调用sendRsp返回。在调用sendRsp返回时,会切回到微信终端程序界面。
}
- (void)onResp:(BaseResp *)resp
{
//如果第三方程序向微信发送了sendReq的请求,那么onResp会被回调。sendReq请求调用后,会切到微信终端程序界面。
NSLog(@"onResp: %@", resp);
if ([resp isKindOfClass:[SendAuthResp class]]){//用户授权后回调
SendAuthResp * result = (SendAuthResp*)resp;
// ERR_OK = 0(用户同意)
// ERR_AUTH_DENIED = -4(用户拒绝授权)
// ERR_USER_CANCEL = -2(用户取消)
if (resp.errCode == 0) {
NSLog(@"SendAuthResp2 %@, %@", result.code, result.state);
//1.result.code 获取code
//2.getToken
//3.getuserinfo
[self getAccess_token:result.code];//2
}else{
//提示授权失败
}
}
}
-(void)getUserInfo:(NSString*)accessToken withOpenID:(NSString*)openID
{
// https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID
NSString *url =[NSString stringWithFormat:@"https://api.weixin.qq.com/sns/userinfo?access_token=%@&openid=%@",accessToken,openID];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSURL *zoneUrl = [NSURL URLWithString:url];
NSString *zoneStr = [NSString stringWithContentsOfURL:zoneUrl encoding:NSUTF8StringEncoding error:nil];
NSData *data = [zoneStr dataUsingEncoding:NSUTF8StringEncoding];
dispatch_async(dispatch_get_main_queue(), ^{
if (data) {
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
/*
{
city = Haidian;
country = CN;
headimgurl = "http://wx.qlogo.cn/mmopen/FrdAUicrPIibcpGzxuD0kjfnvc2klwzQ62a1brlWq1sjNfWREia6W8Cf8kNCbErowsSUcGSIltXTqrhQgPEibYakpl5EokGMibMPU/0";
language = "zh_CN";
nickname = "xxx";
openid = oyAaTjsDx7pl4xxxxxxx;
privilege = (
);
province = Beijing;
sex = 1;
unionid = oyAaTjsxxxxxxQ42O3xxxxxxs;
}
*/
NSLog(@"getUserInfo%@", dic);
}
});
});
}
- (void)refreshAccess_token:(NSString*)refresh_token
{
//refresh_token拥有较长的有效期(30天),当refresh_token失效的后,需要用户重新授权。
//https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=APPID&grant_type=refresh_token&refresh_token=REFRESH_TOKEN
NSString *url =[NSString stringWithFormat:@"https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=%@&grant_type=%@&refresh_token=REFRESH_TOKEN", kWeiXinAppKey, refresh_token];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSURL *zoneUrl = [NSURL URLWithString:url];
NSString *zoneStr = [NSString stringWithContentsOfURL:zoneUrl encoding:NSUTF8StringEncoding error:nil];
NSData *data = [zoneStr dataUsingEncoding:NSUTF8StringEncoding];
dispatch_async(dispatch_get_main_queue(), ^{
if (data) {
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
/*
{
"access_token":"ACCESS_TOKEN",
"expires_in":7200,
"refresh_token":"REFRESH_TOKEN",
"openid":"OPENID",
"scope":"SCOPE"
}
*/
NSLog(@"getAccess_token%@", dic);
[self getUserInfo:dic[@"access_token"] withOpenID:dic[@"openid"]];
}
});
});
}
-(void)getAccess_token:(NSString*)wxCode
{
//获取access_token
// https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code
NSString *url =[NSString stringWithFormat:@"https://api.weixin.qq.com/sns/oauth2/access_token?appid=%@&secret=%@&code=%@&grant_type=authorization_code", kWeiXinAppKey, kWeiXinAppSecret, wxCode];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSURL *zoneUrl = [NSURL URLWithString:url];
NSString *zoneStr = [NSString stringWithContentsOfURL:zoneUrl encoding:NSUTF8StringEncoding error:nil];
NSData *data = [zoneStr dataUsingEncoding:NSUTF8StringEncoding];
dispatch_async(dispatch_get_main_queue(), ^{
if (data) {
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
/*
"access_token" = "OezXcEiiBSKSxW0eoylIeDkHcwRLAAAf2y5ZOMFiIgZgqh8HV4X4b2OYXOM0m7M7k5eEc3U_muSNezPcRkEG_K9w9JFCgyBiFAqoX1r2bNOUGm6eouinITnE0_Y8KN-elHDlCXQIaCKJOvMGk23mcQ";
"expires_in" = 7200;
openid = "okUT8s_748U2PTAva7AePzZ98G5c";
"refresh_token" = "OezXcEiiBSKSxW0eoylIeDkHcwRLAAAf2y5ZOMFiIgZgqh8HV4X4b2OYXOM0m7M7T4jiwpU3RMFneEFq5-0ZM39dDw7XGhWpX6Bi1d8uir12NG1ryKpa0XuxJE7hrtT8B2KKqph-Vux_R4Ty9HAMYA";
scope = "snsapi_userinfo,snsapi_base";
*/
NSLog(@"getAccess_token%@", dic);
[self getUserInfo:dic[@"access_token"] withOpenID:dic[@"openid"]];
}
});
});
}
#pragma mark - Weibo
- (void)didReceiveWeiboRequest:(WBBaseRequest *)request
{
NSLog(@"didReceiveWeiboRequest %@", request);
}
- (void)didReceiveWeiboResponse:(WBBaseResponse *)response
{
NSLog(@"didReceiveWeiboResponse %@", response);
NSString * wbtoken = nil;
NSString * wbCurrentUserID = nil;
NSString * wbRefreshToken = nil;
if ([response isKindOfClass:WBAuthorizeResponse.class])
{
NSString *title = NSLocalizedString(@"认证结果", nil);
NSString *message = [NSString stringWithFormat:@"%@: %d\nresponse.userId: %@\nresponse.accessToken: %@\n%@: %@\n%@: %@", NSLocalizedString(@"响应状态", nil), (int)response.statusCode,[(WBAuthorizeResponse *)response userID], [(WBAuthorizeResponse *)response accessToken], NSLocalizedString(@"响应UserInfo数据", nil), response.userInfo, NSLocalizedString(@"原请求UserInfo数据", nil), response.requestUserInfo];
if ((int)response.statusCode == 0) {
//getuserinfo
wbtoken = [(WBAuthorizeResponse *)response accessToken];
wbCurrentUserID = [(WBAuthorizeResponse *)response userID];
wbRefreshToken = [(WBAuthorizeResponse *)response refreshToken];
[self getWbUserInfo:wbtoken withUid:wbCurrentUserID];//请求用户信息
}
}
}
- (void)getWbUserInfo:(NSString*)access_token withUid:(NSString*)uid
{
NSString *url =[NSString stringWithFormat:@"https://api.weibo.com/2/users/show.json?access_token=%@&uid=%@", access_token, uid];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSURL *zoneUrl = [NSURL URLWithString:url];
NSString *zoneStr = [NSString stringWithContentsOfURL:zoneUrl encoding:NSUTF8StringEncoding error:nil];
NSData *data = [zoneStr dataUsingEncoding:NSUTF8StringEncoding];
dispatch_async(dispatch_get_main_queue(), ^{
if (data) {
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
NSLog(@"getWbUserInfo%@", dic);
}
});
});
}
#pragma mark - Tencent
- (void)tencentDidLogin
{
NSLog(@"tencentDidLogin");
[[NSNotificationCenter defaultCenter] postNotificationName:kLoginSuccessed object:self];
}
- (void)tencentDidNotLogin:(BOOL)cancelled
{
//提示授权失败
}
- (void)tencentDidNotNetWork
{
//提示网络中断
}
6.最后,调用发送授权请求,在所需要的viewController
- (IBAction)loginQq:(id)sender
{
_oauthQQ = [[TencentOAuth alloc] initWithAppId:kTencentAppKey andDelegate:self];
NSArray * permissions = @[@"get_user_info", @"get_simple_userinfo", @"add_t"];
[_oauthQQ authorize:permissions];
}
- (IBAction)loginWeixin:(id)sender
{
SendAuthReq* req =[[SendAuthReq alloc ] init];
req.scope = @"snsapi_userinfo,snsapi_base";
req.state = @"fandian0722" ;
[WXApi sendReq:req];
}
- (IBAction)loginWeibo:(id)sender;
{
WBAuthorizeRequest *request = [WBAuthorizeRequest request];
request.redirectURI = @"http://";
request.scope = @"all";
[WeiboSDK sendRequest:request];
}
7.其它 还在补充中,后续接着更新
完
Jfinal weixin maven id
Jfinal weixin 在maven中的坐标,官网没找到,在码云上得到的:http://git.oschina.net/javen205/weixin_guide/repository/archive/master
<dependency>
<groupId>com.jfinal</groupId>
<artifactId>jfinal-weixin</artifactId>
<version>${weixin.version}</version>
</dependency>
Jfinal weixin 源码分析 --- 碎碎念(看最后,有福利)
我就是要开发微信,可是我行么?
好吧,微信的开发已经不是一年两年的历史了,很多人都问我,假如我想要进行微信开发,我需要准备些什么东西?微信到底是个什么东西,他和我们平常开发的那些个 WebApp 到底有什么样的区别了?会有哪些吭等着我们迈呢?
为了能够解决这个问题,我特别写了这一系列的博客,就是为了给大家一条路,让各位能够不要方。
神器,Jfinal weixin sdk!! 来不及了 赶紧上车
首先介绍一下这个神器,Jfinal weixin 是 Jfinal 框架专门为微信开发而专门开发的一个微信极速开发框架,为我们封装了许多微信的接口和其他的一些输入信息,输出信息的 XML 解析,提供关于菜单操作的一系列方法,总之就是,让我们能够快速的正对业务进行快速实现,让各位新手也能够快速的进入到这个微信开发的项目中去。
有一个问题,我经常被问到,『微信开发难么?大概多久能够入门?需要什么技术栈?还需要什么别的技能?』
答:微信开发,其实和其他的程序开发并没有什么非常大的区别,说句不好听的话,他就是对接微信的接口,基本没有任何技术含量,入门时间基本都在 2 个小时以内,需要的技术栈:HTML+CSS+JS + 后台语言 + MYSQL 之类的数据库(最常规的),基本就是这些。只要你能够读懂微信开发的文档,基本都没有什么问题(读了也白读,微信的开发文档写的不是一般的渣)
从下节开始,我给大家分享 Jfinal 微信框架的源码解读,顺带给大家展示一下,如何去阅读一个开源框架的步骤和方法,希望对大家有点帮助。
奉上自己录的视频链接,有需要的自己下载:
http://pan.baidu.com/s/1i3M5bX7
关于关于jfinal weixin 多公众号的支持和公众号接入多平台的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于cURL error 6: Could not resolve: api.weixin.qq.com (Could not contact DNS servers)、iOS实战:第三方登陆weibo/weixin/qq集成、Jfinal weixin maven id、Jfinal weixin 源码分析 --- 碎碎念(看最后,有福利)的相关信息,请在本站寻找。
本文标签: