如何在出生日期自动在Facebook朋友墙上发布消息

时间:2013-01-15 11:28:05

标签: android facebook facebook-graph-api android-facebook

我正在编写一个应用程序,我允许用户在朋友的墙上发布消息,方法是点击 ListView项目行

但是现在我想让用户写一条消息,在出生日期自动发送他/她的朋友......

简而言之,在他/她的出生日期自动发送愿望给朋友....

我使用以下代码在墙上发布消息

  public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
//  Log.d(LOG_TAG, "onItemClick()");

     try {
            final long friendId;
            friendId = jsonArray.getJSONObject(position).getLong("uid");
            String name = jsonArray.getJSONObject(position).getString("name");
            new AlertDialog.Builder(this).setTitle(R.string.post_on_wall_title)
                    .setMessage(String.format(getString(R.string.post_on_wall), name))
                    .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Bundle params = new Bundle();

                            params.putString("to", String.valueOf(friendId));
                            params.putString("caption", getString(R.string.app_name));
                            params.putString("description", getString(R.string.app_desc));
                            params.putString("picture", FacebookUtility.HACK_ICON_URL);
                            params.putString("name", getString(R.string.app_action));
                            FacebookUtility.facebook.dialog(FriendsList.this, "feed", params,
                                    (DialogListener) new PostDialogListener());
                        }

                    }).setNegativeButton(R.string.no, null).show();
        } catch (JSONException e) {
            showToast("Error: " + e.getMessage());
        }
    }

    public class PostDialogListener extends BaseDialogListener {
        @Override
        public void onComplete(Bundle values) {
            final String postId = values.getString("post_id");
            if (postId != null) {
                showToast("Message posted on the wall.");
            } else {
                showToast("No message posted on the wall.");
            }
        }
    }

    public void showToast(final String msg) {

        mHandler.post(new Runnable() {
            @Override
            public void run() {
                Toast toast = Toast.makeText(FriendsList.this, msg, Toast.LENGTH_LONG);
                toast.show();
            }
        });
    }

我需要指导,在生日日期自动发送消息....

0 个答案:

没有答案