繁体   English   中英

如何获得Facebook朋友即将生日的通知/提醒

[英]How to get Notification/Reminder for Facebook Friends Upcoming Birthdays

我正在编写一个应用程序,其中正在获取所有我的Facebook朋友的列表 ..

但是现在我想在我的应用程序中添加其他功能, 以获取即将到来的朋友生日的通知/提醒

我正在使用下面的代码来获取所有朋友的列表:

 public class FriendListAdapter extends BaseAdapter implements
        SectionIndexer {
    private LayoutInflater mInflater;

    private GetProfilePictures picturesGatherer = null;
    FriendsList friendsList;
    private String[] sections;

    Hashtable<Integer, FriendItem> listofshit = null;

    public FriendListAdapter(FriendsList friendsList) {

        this.friendsList = friendsList;
        sections = new String[getCount()];
        listofshit = new Hashtable<Integer, FriendItem>();


        for (int i = 0; i < getCount(); i++) {
            try {

                sections[i] = jsonArray.getJSONObject(i).getString("name")
                        .substring(0);
                sections[i] = jsonArray.getJSONObject(i)
                        .getString("birthday").substring(1);


            } catch (JSONException e) {
                sections[i] = "";

            }
        }
        if (picturesGatherer == null) {
            picturesGatherer = new GetProfilePictures();
        }
        picturesGatherer.setAdapterForListener(this);
        mInflater = LayoutInflater.from(friendsList.getBaseContext());
    }

    public int getCount() {

        if (jsonArray == null)
            return 0;
        return jsonArray.length();
    }

    public Object getItem(int position) {

        return listofshit.get(position);
    }

    public long getItemId(int position) {

        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {


        JSONObject jsonObject = null;
        try {
            jsonObject = jsonArray.getJSONObject(position);
        } catch (JSONException e) {

        }

        FriendItem friendItem;

        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.single_friend, null);
            friendItem = new FriendItem();

            convertView.setTag(friendItem);
        } else {
            friendItem = (FriendItem) convertView.getTag();
        }

        friendItem.friendPicture = (ImageView) convertView
                .findViewById(R.id.picture_square);
        friendItem.friendName = (TextView) convertView
                .findViewById(R.id.name);
        friendItem.friendDob = (TextView) convertView
                .findViewById(R.id.dob);
        friendItem.friendLayout = (RelativeLayout) convertView
                .findViewById(R.id.friend_item);

        try {
            String uid = jsonObject.getString("uid");
            String url = jsonObject.getString("pic_square");
            friendItem.friendPicture.setImageBitmap(picturesGatherer
                    .getPicture(uid, url));
        } catch (JSONException e) {

            friendItem.friendName.setText("");
            friendItem.friendDob.setText("");
        }

        try {
            friendItem.friendName.setText(jsonObject.getString("name"));
            friendItem.friendDob.setText(jsonObject.getString("birthday"));
        } catch (JSONException e) {

            friendItem.friendName.setText("");
            friendItem.friendDob.setText("");
        }

        listofshit.put(position, friendItem);
        return convertView;
    }

    public int getPositionForSection(int position) {
        return position;
    }

    public int getSectionForPosition(int position) {
        return position;
    }

    public Object[] getSections() {
        return sections;
    }
}

您可以使用CRON和facebook的Notification API

  1. 首先,你需要存储的ID和数据库用户扩展访问令牌
  2. 然后,运行您的调度程序,并使用用户的令牌获取每个用户的朋友的生日
  3. 使用通知API将通知发送给用户(只需要APP访问令牌 -您可以从此处获取)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM