-QQAPI- QQApi.m:428 param error: nil object


Warning: array_keys() expects parameter 1 to be array, null given in /usr/local/nginx/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 2058

Warning: Invalid argument supplied for foreach() in /usr/local/nginx/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 2058

Warning: Invalid argument supplied for foreach() in /usr/local/nginx/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 2430

Warning: implode(): Argument must be an array in /usr/local/nginx/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3384

Warning: array_keys() expects parameter 1 to be array, null given in /usr/local/nginx/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3407

Warning: Invalid argument supplied for foreach() in /usr/local/nginx/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3407

Warning: Invalid argument supplied for foreach() in /usr/local/nginx/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3448

Warning: array_keys() expects parameter 1 to be array, null given in /usr/local/nginx/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3500

Warning: Invalid argument supplied for foreach() in /usr/local/nginx/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3500

Warning: array_keys() expects parameter 1 to be array, null given in /usr/local/nginx/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3644

Warning: Invalid argument supplied for foreach() in /usr/local/nginx/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3644

Warning: array_keys() expects parameter 1 to be array, null given in /usr/local/nginx/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 2058

Warning: Invalid argument supplied for foreach() in /usr/local/nginx/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 2058

Warning: Invalid argument supplied for foreach() in /usr/local/nginx/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 2430

Warning: implode(): Argument must be an array in /usr/local/nginx/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3384

Warning: array_keys() expects parameter 1 to be array, null given in /usr/local/nginx/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3407

Warning: Invalid argument supplied for foreach() in /usr/local/nginx/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3407

Warning: Invalid argument supplied for foreach() in /usr/local/nginx/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3448

Warning: array_keys() expects parameter 1 to be array, null given in /usr/local/nginx/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3500

Warning: Invalid argument supplied for foreach() in /usr/local/nginx/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3500

Warning: array_keys() expects parameter 1 to be array, null given in /usr/local/nginx/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3644

Warning: Invalid argument supplied for foreach() in /usr/local/nginx/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3644

0、先说现象:找开App在使用QQ分享时提示“参数错误”,第一次分享时都会这样,重复操作一切正常!

1、正常情况下项目中使用QQ分享功能,只需要创建分享对象,然后调用接口分享即可,官方代码示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
NSString *utf8String = @"http://www.163.com";
NSString *title = @"新闻标题";
NSString *description = @"新闻描述";
NSString *previewImageUrl = @"http://cdni.wired.co.uk/620x413/k_n/NewsForecast%20copy_620x413.jpg";
QQApiNewsObject *newsObj = [QQApiNewsObject
                            objectWithURL:[NSURL URLWithString:utf8String]
                            title:title
                            description:description
                            previewImageURL:[NSURL URLWithString:previewImageUrl]];
SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:newsObj];
//将内容分享到qq
//QQApiSendResultCode sent = [QQApiInterface sendReq:req];
//将内容分享到qzone
QQApiSendResultCode sent = [QQApiInterface SendReqToQZone:req];

2、然而官方没有提醒你,在此之前必须先将TencentOAuth对象实例化,即必须先执行以下代码:

1
self.oauth = [[TencentOAuth alloc] initWithAppId:kSAAppID_QQ andDelegate:self];

3、理论上有这些就足够了,但事实并非如此,比如说官方的Demo在分享时控制台会有一个logo输出

1
2016-08-19:11:46:11:504 -QQAPI- ConfigManager.m:117 @_@

4、虽然看不懂这是什么意思,官方文档也没有给出相关说明,但我想一定是不正常的,我自己写一个简单的Demo来实现分享功能,调用时也会有这样的提示!

5、关键问题来了,实际项目中使用QQ分享功能,同样的按照上述两部来操作,结果并不如我们所愿,先看控制器输出:

1
2
2016-08-19:11:46:11:504 -QQAPI- ConfigManager.m:117 @_@
2016-08-19:11:46:11:519 -QQAPI- QQApi.m:428 param error: nil object

6、程序中调用分享返回的QQApiSendResultCode结果为EQQAPIMESSAGECONTENTNULL,与控制台输出的这个提示相对应,意思是说我分享时输入的QQApiObject对象为空!也就是说如果你将上述示例代码中[SendMessageToQQReq reqWithContent:newsObj]调用时newsObj传空值也会得到同样的结果反馈;

7、更加让人不以明白的是,再次分享就成功了,每次重新启动App都会出现第一次分享失败,后续就一切正常了,何解?!

-QQAPI- QQApi.m:428 param error: nil object》有2个想法

    1. Sian 文章作者

      没解决,官方的文档不全,也没办法调试,错误代码也没个相关说明,暂时自己写了一些纠错的逻辑,感觉治标不治本还存在一定隐患。

发表回复