2012-01-17 4 views
1

this postthis tutorialの助けを借りて、自分のアンドロイドアプリにfacebookを最新のFacebookSDKと統合することができました。私はいくつかのコンテンツを公開したいので、チュートリアルとその作業は完全にうまくいっています...私の唯一の問題は、公開ダイアログボックス(チュートリアルで述べたように)を見ることができないことです。ユーザーにメッセージの内容を変更してもらいたい...どうすればいいのですか?アンドロイドの最新facebookSDKを使ってアンドロイドとFacebookの統合を使用するときに公開ダイアログボックスを表示する方法

ここに投稿を公開するために使用しているコードのスナップショットがあります。

private static final String[] PERMISSIONS = new String[] {"publish_stream"}; 

としての権限を持つ

public void postToWall(String message){ 
    Bundle parameters = new Bundle(); 
      parameters.putString("message", message); 
      parameters.putString("description", "topic share"); 
      try { 
       facebook.request("me"); 

     String response = facebook.request("me/feed", parameters, "POST"); 

     Log.d("Tests", "got response: " + response); 
     if (response == null || response.equals("") || 
       response.equals("false")) { 
      showToast("Blank response."); 
     } 
     else { 
      showToast("Message posted to your facebook wall!"); 
     } 
     finish(); 
    } catch (Exception e) { 
     showToast("Failed to post to wall!"); 
     e.printStackTrace(); 
     finish(); 
    } 
} 

私もfacebook.dialog(と呼ばれるものがあることがわかった)が、私は考え、どのようにそれを使用するがありません...

そうしてください公開ダイアログボックスを表示する方法を教えてください。

は、あなたが使用

ラジ

答えて

1

コードは、ダイアログなしで壁に公開します、ありがとうございました。コードスニペット以下

my only issue is that I am not able to see the publish dialog box (as mentioned in the tutorial), where as I want it to be shown as I want user to modify the contents of the message.. 

使用すると、ダイアログを表示しますauthenticatedFacebookはFacebookのオブジェクトをある

private void post_facebook() { 
    Bundle parameters = new Bundle(); 
    parameters.putString("method", "stream.publish"); 

    JSONObject attachment = new JSONObject(); 

    try { 
     attachment.put("message", "Messages"); 
     attachment.put("name", "Check out"); 
     attachment.put("href", "http://www.google.com"); 
    } catch (JSONException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 

    parameters.putString("attachment", attachment.toString()); 

    authenticatedFacebook.dialog(Activity.this, "stream.publish",parameters, new TestUiServerListener()); 
} 

    public class TestUiServerListener implements DialogListener { 
    public void onComplete(Bundle values) { 
     final String postId = values.getString("post_id"); 
     if (postId != null) { 
      new AsyncFacebookRunner(authenticatedFacebook).request(postId,new TestPostRequestListener()); 
     } else { 
      Activity.this.runOnUiThread(new Runnable() { 
       public void run() { 
       } 
      }); 
     } 
    } 

    public void onCancel() { 
    } 

    public void onError(DialogError e) { 
     e.printStackTrace(); 
    } 

    public void onFacebookError(FacebookError e) { 
     e.printStackTrace(); 
    } 
} 

public class TestPostRequestListener implements RequestListener { 
    public void onComplete(final String response, final Object state) { 
     try { 
      JSONObject json = Util.parseJson(response); 
      String postId = json.getString("id"); 
      Activity.this.runOnUiThread(new Runnable() { 
       public void run() { 
       } 
      }); 
     } catch (Throwable e) { 
     } 
    } 

    public void onFacebookError(FacebookError e, final Object state) { 
     e.printStackTrace(); 
    } 

    public void onFileNotFoundException(FileNotFoundException e, 
      final Object state) { 
     e.printStackTrace(); 
    } 

    public void onIOException(IOException e, final Object state) { 
     e.printStackTrace(); 
    } 

    public void onMalformedURLException(MalformedURLException e, 
      final Object state) { 
     e.printStackTrace(); 
    } 
} 

+0

ありがとうございました... – Nik

+0

こんにちはVenky、私はまたあなたが使用している添付ファイルについてもっと知る必要があります...特定のURLを画像と共有する必要があるため – Nik

関連する問題