-1

壁に写真を送信する有効な方法が見つかりません。私のコードは、そうしないということです。

Bundle postParams = new Bundle();
    postParams.putByteArray("image", byteArray);
    postParams.putString("message", "A wall picture");

    Session session = Session.getActiveSession();
    if (session != null) {

        Log.e("Session", "don t null");
        Request request = new Request(session, "me/feed", postParams,
                HttpMethod.POST);
        RequestAsyncTask task = new RequestAsyncTask(request);
        task.execute();
4

1 に答える 1

0

電話から写真を送信したことはありませんが、画像リンクを使用してサーバーから送信しました。ほとんどのロジックは似ているため、役立つ場合に備えてこのコードを配置します。

final Bundle parameters = new Bundle();
parameters.putString("name", getString(R.string.app_name));
parameters.putString("caption", "haha");
parameters.putString("link", "www.google.com");
parameters.putByteArray("picture", byteArray);//I took this one from your code. My key is "picture" instead of "image"
Session.openActiveSession(this, true, new StatusCallback() {

    @Override
    public void call(Session session, SessionState state, Exception exception) {
        if (session.isOpened()) {
            new FeedDialogBuilder(EndGameActivity.this, session, parameters).build().show();

            //you can try this one instead of the one above if you want, but both work well
            //Request.newMeRequest(session, new Request.GraphUserCallback() {
            //
            //    @Override
            //    public void onCompleted(GraphUser user, Response response) {
            //        final Session session = Session.getActiveSession();
            //        new FeedDialogBuilder(EndGameActivity.this, session, parameters).build().show();
            //    }
            //}).executeAsync();
        }

    }
});

Request.newMeRequestこのコードは、最近導入された最新の Facebook SDK 3.5 でのみ機能し、Request.executeMeRequestAsync廃止された の代わりに使用する必要があります。

また、使用するキーが「画像」ではなく「画像」であることにも注意してください。多分それはあなたのコードの問題です。

しかしonClick、ユーザーがボタンに触れると、イベント内でそれを行います。なぜあなたのonCreate方法でそれが必要なのですか?

于 2013-08-22T07:16:39.820 に答える