宝塔服务器面板,一键全能部署及管理,送你10850元礼包,点我领取

 response{“data”:null,”detailerrinfo”:{“accesstoken”:””,”apiname”:”weibo.user.info”,”appkey”:”801306361″,”clientip”:”110.184.110.97″,”cmd”:0,”proctime”:0,”ret1″:3,”ret2″:3,”ret3″:101,”ret4″:2502133002,”timestamp”:1372144511},”errcode”:101,”msg”:”missing parameter”,”ret”:3,”seqid”:5893315800140711293}


从信息可以看出:缺少必要的参数。向oAuthV2对象中加入参数——

oAuthV2.setOpenid(“opnid”);   //opnid:授权成功后,返回的oAuthV2里面用 getOpenid() 方法获取

oAuthV2.setOpenkey(“opkey”);   //getOpenkey() 获得

还有加上

oAuth.setClientId(app_key);   //申请的app——key

oAuth.setClientSecret(clientSecret);  //注册时候获得

在第一次授权后,我们把

oAuthV2保存在了SharedPreferences里面,应该少保存了2个数据:openid,和 opkey,和新浪微博的有些不一样,新浪的只需要保存token,和过期时间。


腾讯的还需要保存:openid,和 opkey,在我们发送微博的时候需要用到2个参数。

 

public staticvoid saveDate(Context context, OAuthV2 token) { //保存第一次授权后,获取的OAuthV2,注意红色部分,必须保存

preferences = context

.getSharedPreferences(“tenxun”, Context.MODE_PRIVATE);

Editor editor = preferences.edit();

editor.putString(“token”, token.getAccessToken());

editor.putString(“expiresTime”, token.getExpiresIn());

editor.putString(“openid”, token.getOpenid()); 

editor.putString(“opkey”, token.getOpenkey());

editor.commit();

 

}

public static OAuthV2 getDate(Context context)    //获取保存的oAuthV2,注意红色部分

{

OAuthV2 oAuthV2=new OAuthV2();

preferences = context

.getSharedPreferences(“tenxun”, Context.MODE_PRIVATE);

 

oAuthV2.setAccessToken(preferences.getString(“token”,“”));

oAuthV2.setExpiresIn(preferences.getString(“expiresTime”,null));

oAuthV2.setOpenid(preferences.getString(“openid”, null));

oAuthV2.setOpenkey(preferences.getString(“opkey”, null));

return oAuthV2;

}