萝莉来了 v1.2.1版本的 MD5 值为:6055c21e001561c5b114d0da5b392fcb
以下内容为反编译后的 ShareSina.java 源代码,内容仅作参考
package com.gamegoo.loligo.share;
import android.content.Context;
import android.os.Bundle;
import com.gamegoo.loligo.util.Tutil;
import com.gamegoo.loligo.vampire;
import com.weibo.sdk.android.Oauth2AccessToken;
import com.weibo.sdk.android.Weibo;
import com.weibo.sdk.android.WeiboAuthListener;
import com.weibo.sdk.android.WeiboDialogError;
import com.weibo.sdk.android.WeiboException;
import com.weibo.sdk.android.WeiboParameters;
import com.weibo.sdk.android.net.AsyncWeiboRunner;
import com.weibo.sdk.android.net.RequestListener;
import java.io.File;
import java.io.IOException;
public class ShareSina {
public static final String TAG = "sinasdk";
private static final String kDefaultShareImage = "screenshot.png";
private static final String kDefaultShareText = "爱速度,爱激情,爱萝莉,爱冲击,不喜欢停止战斗,只爱勇往直前,我玩的是萝莉来了. 下载: http://llll.punchbox.org";
private static final String kShareSuccessText = "分享成功";
private static final String kSinaAppKey = "3330042723";
private static final String kSinaAppSecret = "cf37382453b860f30401728d1d9987dd";
private static final String kSinaRedirectURL = "http://e.weibo.com/3339519422/profile";
public static final String kSinaSERVER = "https://api.weibo.com/2/";
public static final String kSinaURL_ACCESS_TOKEN = "http://api.t.sina.com.cn/oauth/access_token";
public static final String kSinaURL_AUTHENTICATION = "http://api.t.sina.com.cn/oauth/authenticate";
public static final String kSinaURL_AUTHORIZE = "http://api.t.sina.com.cn/oauth/authorize";
public static final String kSinaURL_OAUTH2_ACCESS_TOKEN = "https://api.weibo.com/oauth2/access_token";
public static final String kSinaURL_OAUTH_TOKEN = "http://api.t.sina.com.cn/oauth/request_token";
private Context context = null;
private Weibo sina_weibo = null;
public static Oauth2AccessToken accessToken = null;
private static ShareSina s_sina = null;
private static String str_share_txt = "";
private static String str_share_image_absolute_path = "";
public static ShareSina I() {
if (s_sina == null) {
s_sina = new ShareSina();
if (s_sina.sina_weibo == null) {
s_sina.sina_weibo = Weibo.getInstance(kSinaAppKey, kSinaRedirectURL);
}
}
return s_sina;
}
public void setContent(Context o) {
this.context = o;
}
public void authorize() {
this.sina_weibo.authorize(this.context, new AuthDialogListener());
}
public static void share() {
vampire.I().runOnUiThread(new Runnable() {
@Override
public void run() {
ShareSina.I().shareWeibo("爱速度,爱激情,爱萝莉,爱冲击,不喜欢停止战斗,只爱勇往直前,我玩的是萝莉来了. 下载: http://llll.punchbox.org", "screenshot.png");
}
});
}
public void shareWeibo(String txt, String image) {
if (this.context != null && txt != null) {
str_share_txt = txt;
if (image != null) {
str_share_image_absolute_path = Tutil.getWriteablePath(this.context) + image;
File f = new File(str_share_image_absolute_path);
if (!f.exists()) {
str_share_image_absolute_path = "";
}
}
accessToken = AccessTokenKeeper.readAccessToken(this.context);
if (accessToken != null && !accessToken.isSessionValid()) {
I().authorize();
} else {
shareImageImplement();
}
}
}
public void shareImageImplement() {
String url;
System.out.println("sina_sdk: shareTextImplement");
String img_path = str_share_image_absolute_path;
String weibo_txt = str_share_txt;
WeiboParameters params = new WeiboParameters();
params.add("source", kSinaAppKey);
params.add(Weibo.KEY_TOKEN, accessToken.getToken());
params.add("status", weibo_txt);
if (img_path != "") {
params.add("pic", img_path);
url = "https://api.weibo.com/2/statuses/upload.json";
} else {
url = "https://api.weibo.com/2/statuses/update.json";
}
AsyncWeiboRunner.request(url, params, "POST", new SinaRequestListener());
}
public class SinaRequestListener implements RequestListener {
SinaRequestListener() {
}
@Override
public void onComplete(String response) {
System.out.println("sina_sdk: openUrl ok " + response);
vampire.I();
vampire.showStringDialog(ShareSina.kShareSuccessText);
vampire.I();
vampire.sendEventFromJavaToCpp(vampire.s_jc_share_wb_success, null, null);
}
@Override
public void onIOException(IOException e) {
}
@Override
public void onError(WeiboException e) {
}
}
public class AuthDialogListener implements WeiboAuthListener {
AuthDialogListener() {
}
@Override
public void onComplete(Bundle values) {
String token = values.getString(Weibo.KEY_TOKEN);
String expires_in = values.getString(Weibo.KEY_EXPIRES);
ShareSina.accessToken = new Oauth2AccessToken(token, expires_in);
if (ShareSina.accessToken.isSessionValid()) {
System.out.println("sina_sdk: auth complete");
ShareSina.I().shareImageImplement();
}
}
@Override
public void onError(WeiboDialogError e) {
}
@Override
public void onCancel() {
}
@Override
public void onWeiboException(WeiboException e) {
}
}
}