本文整理汇总了Java中com.weibo.net.Weibo类的典型用法代码示例。如果您正苦于以下问题:Java Weibo类的具体用法?Java Weibo怎么用?Java Weibo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Weibo类属于com.weibo.net包,在下文中一共展示了Weibo类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doInBackground
import com.weibo.net.Weibo; //导入依赖的package包/类
@Override
protected ApiResult doInBackground(String... uid) {
ApiResult u = null;
Map<String, Object> p = new HashMap<String, Object>();
p.put("email", uid[0]);
p.put("user_name", uid[1]);
p.put("password", uid[2]);
p.put("user_status", "2001");
p.put("user_id", userId);
if(weiboUser != null){
Weibo weibo = Weibo.getInstance();
p.put("profile_pic_url", weiboUser.getString("profile_image_url"));
p.put("ref_uid", weiboUser.getString("id"));
p.put("ref_token", weibo.getAccessToken().getToken());
p.put("ref_type", "sina");
}
u = client.registerUser(p);
return u;
}
示例2: onComplete
import com.weibo.net.Weibo; //导入依赖的package包/类
@Override
public void onComplete(Bundle values) {
String token = values.getString("access_token");
String expires_in = values.getString("expires_in");
AccessToken accessToken = new AccessToken(token, Weibo.getAppSecret());
accessToken.setExpiresIn(expires_in);
Weibo.getInstance().setAccessToken(accessToken);
client.saveSettings(Constants.PREFS_SINA_ACCESS_TOKEN, token);
client.saveSettings(Constants.PREFS_SINA_EXPIRES_IN, expires_in);
Log.d("tag", "done, token:" + token + ", expires_in:" + expires_in);
/**
* 如果用户已经登录,不需要再次绑定用户信息。只是刷新一下围脖授权。
*/
new GetSinaUserInfoTask(token, values.getString("uid"), WebLoginActivity.this, handler).start();
//new GetUserInfoTask(token, values.getString("uid")).start();
}
示例3: SsoHandler
import com.weibo.net.Weibo; //导入依赖的package包/类
public SsoHandler(Activity activity, Handler handler) {
mAuthActivity = activity;
if(handler != null){
this.handler = handler;
}
mWeibo = Weibo.getInstance();
mWeibo.setupConsumerConfig(Constants.SINA_APPID, Constants.SINA_APPKEY);
mWeibo.setRedirectUrl(Constants.SINA_CALLBACK);
//Weibo.isWifi=Utility.isWifi(activity);
conn = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
/**
* 为啥在Disconnected的时候启动登陆窗口?
*/
//mWeibo.startAuthDialog(mAuthActivity, mAuthDialogListener);
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
RemoteSSO remoteSSOservice = RemoteSSO.Stub.asInterface(service);
try {
ssoPackageName = remoteSSOservice.getPackageName();
ssoActivityName = remoteSSOservice.getActivityName();
boolean singleSignOnStarted = startSingleSignOn(
mAuthActivity, Constants.SINA_APPID, new String[]{},
mAuthActivityCode);
if (!singleSignOnStarted) {
startWebLogin();
}
} catch (RemoteException e) {
e.printStackTrace();
}
}
};
}
示例4: startRegisterNew
import com.weibo.net.Weibo; //导入依赖的package包/类
private void startRegisterNew(String token, String sinaId, JSONObject obj){
Log.d("tag", "do Register, uid:" + sinaId);
Intent intent = new Intent();
intent.putExtra(Weibo.TOKEN, token);
intent.putExtra("uid", sinaId);
try {
intent.putExtra("userId", obj.getString("user_id"));
} catch (JSONException e) {
}
intent.setClass(context, RegisterActivity.class);
context.startActivity(intent);
}
示例5: onCreate
import com.weibo.net.Weibo; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.share_to_weibo);
loading = new ProgressDialog(this);
loading.requestWindowFeature(Window.FEATURE_NO_TITLE);
loading.setMessage("登录中...");
Intent intent = this.getIntent();
picUrl = intent.getStringExtra("picUrl");
String text = intent.getStringExtra("text");
link = intent.getStringExtra("link");
message = (TextView)findViewById(R.id.share_text);
imageView = (ImageView)findViewById(R.id.taoke_pic);
Display display = null;
display = getWindowManager().getDefaultDisplay();
int disWidth = display.getWidth();
client.tmpImgLoader.loadImage(picUrl, imageView, disWidth, true); // .cache.get(picUrl, disWidth, true,true);
message.setText(text);
weibo = Weibo.getInstance();
weibo.setupConsumerConfig(Constants.SINA_APPID, Constants.SINA_APPKEY);
progress = (ProgressBar) findViewById(R.id.progressbar_loading);
progress.setVisibility(View.GONE);
if(weibo.getAccessToken() == null){
String accessToken = client.getSettings(Constants.PREFS_SINA_ACCESS_TOKEN);
String expires_in = client.getSettings(Constants.PREFS_SINA_EXPIRES_IN);
if(accessToken != null){
AccessToken token = new AccessToken(accessToken, Weibo.getAppSecret());
token.setExpiresIn(expires_in);
weibo.setAccessToken(token);
}
}
}
示例6: onResume
import com.weibo.net.Weibo; //导入依赖的package包/类
protected void onResume (){
super.onResume();
processBar.setVisibility(View.VISIBLE);
Weibo mWeibo = Weibo.getInstance();
mWeibo.setupConsumerConfig(Constants.SINA_APPID, Constants.SINA_APPKEY);
mWeibo.setRedirectUrl(Constants.SINA_CALLBACK);
sinaService = new WeiboLoginService(this, web, Weibo.getInstance(), loginListener, processBar);
sinaService.startLogin();
/*
new Thread(){
public void run(){
AppConfig cfg = client.config();
Weibo weibo = Weibo.getInstance();
String key = cfg.getString(AppConfig.SINA_APP_KEY);
String secret = cfg.getString(AppConfig.SINA_APP_SECRET);
String callback = cfg.getString(AppConfig.SINA_APP_CALLBACK);
if(key != null && key.length() > 0 && secret != null && secret.length() > 0){
weibo.setupConsumerConfig(key, secret);
weibo.setRedirectUrl(callback);
sinaService.startLogin();
}else {
Message msg = handler.obtainMessage(GetSinaUserInfoTask.LOGIN_MSG, "应用配置信息更新错误。");
}
}
}.start();
*/
}
示例7: doLoginFromSina
import com.weibo.net.Weibo; //导入依赖的package包/类
public void doLoginFromSina(View v){
Log.d("tag", "doLoginFrom sina");
if(this.isLoginSina){
logoutRef(Constants.AUTH_REF_SINA);
Weibo.getInstance().setAccessToken(null);
}else {
sinaSSO = new SsoHandler(this, sinaHandler);
loading.show();
sinaSSO.authorize();
}
}
示例8: WeiboLoginService
import com.weibo.net.Weibo; //导入依赖的package包/类
public WeiboLoginService(Context ctx, WebView web, Weibo weibo, WeiboDialogListener webListener, ProgressBar bar){
web.setWebViewClient(new WeiboWebViewClient());
//web.loadUrl(mUrl);
this.web = web;
this.mWeibo = weibo;
this.mAuthDialogListener = webListener;
this.bar = bar;
this.ctx = ctx;
}
示例9: startLogin
import com.weibo.net.Weibo; //导入依赖的package包/类
public void startLogin(){
WeiboParameters params = new WeiboParameters();
params.add("client_id", mWeibo.getAppKey());
params.add("response_type", "token");
params.add("redirect_uri", mWeibo.getRedirectUrl());
params.add("display", "mobile");
String url = Weibo.URL_OAUTH2_ACCESS_AUTHORIZE + "?" + Utility.encodeUrl(params);
Utility.setAuthorization(new Oauth2AccessTokenHeader());
CookieSyncManager.createInstance(ctx);
web.loadUrl(url);
}
示例10: initWeibo
import com.weibo.net.Weibo; //导入依赖的package包/类
/**
* 初始化weibo
*/
public static void initWeibo()
{
weibo = Weibo.getInstance();
weibo.setupConsumerConfig(CONSUMER_KEY, CONSUMER_SECRET);
weibo.setRedirectUrl(REDIRECT_URL);
}
示例11: onShareToWeibo
import com.weibo.net.Weibo; //导入依赖的package包/类
public void onShareToWeibo(View v){
progress.setVisibility(View.VISIBLE);
Button btn = (Button)v;
btn.setClickable(false);
new Thread(){
public void run(){
WeiboParameters bundle = new WeiboParameters();
//bundle.add("access_token", token[0]);
String url = Weibo.SERVER + "statuses/upload.json";
String weiBo = message.getText().toString();
String json = null;
ApiResult result = new ApiResult();
//Display display = getWindowManager().getDefaultDisplay();
//final int disWidth = display.getWidth();
File cacheFile = client.tmpImgLoader.cache.getCachedFile(picUrl, 400);
if(cacheFile == null || !cacheFile.isFile()){
showToast("获取图片失败啦~");
return;
}
bundle.add("pic", cacheFile.getAbsolutePath());
bundle.add("status", weiBo + " " + link);
Log.d("weibo", "start to update weibo ...");
try {
synchronized(weibo){
//bundle.add("source", Weibo.getAppKey());
if(weibo.getAccessToken() != null){
bundle.add("access_token", weibo.getAccessToken().getToken());
}
json = weibo.request(ShareToWeiboActivity.this, url, bundle, Utility.HTTPMETHOD_POST,
weibo.getAccessToken());
}
Log.i("weibo", json);
result.json = (JSONObject) new JSONTokener(json).nextValue();
if(result.getString("idstr") != null){
showToast("分享微博成功");
}else {
showToast("分享微博失败, 错误code:" + result.getString("error_code"));
}
String code = result.getString("error_code");
Log.w("weibo", "error code:" + code);
if(code != null){
if(code.equals("21301") || code.equals("21315") ||
code.equals("21327") || code.equals("21327")){
client.removeSettings(Constants.PREFS_SINA_ACCESS_TOKEN);
weibo.setAccessToken(null);
}
}
} catch (Exception e) {
Log.e("weibo", e.toString(), e);
showToast("分享微博失败");
//e.printStackTrace();
}
}
}.start();
finish();
}