实际上我有一个问题 - 我确实在我的应用程序中登录了 Facebook。我也可以做用户授权的墙贴,但是我每次都需要调用授权 - 这需要一些时间并导致屏幕上(短时间内)有一个带有生成(诱导)Facebook 的白色背景 ( https://dl.dropbox.com/u/41114685/1.JPG )。这就是为什么我感兴趣的是,是否有可能在用户的墙上做一个帖子不会导致,每次一个方法进行身份验证(使帖子出方法onComplete())?我希望能得到你的帮助。
package expir.java.file;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import com.facebook.android.DialogError;
import com.facebook.android.Facebook;
import com.facebook.android.Facebook.DialogListener;
import com.facebook.android.FacebookError;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
public class FacebookAuthorizeAndPost implements DialogListener{
FacebookAuthorizeAndPost(Activity activity){
this.activity = activity;
}
public void facebookAuthorize(){
facebookClient = new Facebook(APP_ID);
facebookClient.authorize(activity, new String[]{"publish_stream"}, Facebook.FORCE_DIALOG_AUTH, this);
}
public void onComplete(Bundle values) {
if (values.isEmpty())
{
return;
}
if (!values.containsKey("post_id"))
{
try
{
Bundle cont = new Bundle();
cont.putString("message", "bla-bla-bla");
cont.putString("name", "Testing facebook");
cont.putString("link", "www.????????.com");
cont.putString("description", "This is a funny real test!!! This is a funny real test!!! This is a funny real test!!! This is a funny real test!!!");
cont.putString("picture", "http://code.google.com/p/android-developer-scripts/logo?cct=1294556390");
//facebookClient.dialog(activity, "feed", cont, this);
facebookClient.request("me/feed", cont, "POST");
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}
public void onFacebookError(FacebookError e) {
//
}
public void onError(DialogError e) {
//
}
public void onCancel() {
//
}
public Activity activity;
private final String APP_ID = "??????????????????";
private Facebook facebookClient;
}