How to send Facebook apprequests/notifications with custom message parameter?

时光毁灭记忆、已成空白 提交于 2019-12-06 12:13:09

问题


I'm currently developing a Facebook canvas app in which I let the users invite others to use the app, pretty standard stuff. For this I'm using the FB.ui method of the JavaScript SDK.

FB.ui({
    method: 'apprequests',
    title: "Title",
    message: 'Custom Message',
    to: UserIDs
});

Which currently renders this UI dialog. See this image (notice the Preview section with standard invite message):

The invited user then receives the standard message: USER_NAME sent you a APP_NAME request. However, as it is always the case, we want the user to get a custom message in the first notification (At least this is for a charity donation campaign!). I have read through Facebook documentation and I am aware that user-to-user requests in which the recipient has not installed the app supposedly do not display the message parameter. Nonetheless, I know for a fact (because I have received them!) that certain apps are being able to send custom messages to users that have not installed them. For example, this UI request dialog (notice the custom message in the preview area):

I know there are alternate ways to send notifications, e.g. the Notifications API, currently in Beta. But they seem to be subject to the same restriction.

I would really appreciate if someone could help me to figure out how those apps are generating these requests with custom messages.


回答1:


As detailed in this post http://facebook.stackoverflow.com/questions/6297853/facebook-requests-dialog-not-showing-message-to-recepient you need to use the undocumented new_style_message boolean parameter.

   FB.ui({method:'apprequests',
      title:'Custom window title',
      to: [1,2,3],
      message:'the custom application message',
      new_style_message:true
   }, function (response) {;});

And the correct message will be sent along with your application request.




回答2:


Nonetheless, I know for a fact (because I have received them!) that certain apps are being able to send custom messages to users that have not installed them.

These are most likely “big players”, who have gotten white-listed by Facebook to do so.




回答3:


What you are asking has been removed by Facebook a while ago because of all the abuse (spam).

You can still use the message parameter.

Facebook docs:

The message value is displayed in Notifications and can also be viewed on the Apps and Games Dashboard. Invites (requests where the recipient has not installed the app) do not display this value.

So for example:

function sendRequestToRecipients() {
        var user_ids = document.getElementsByName("user_ids")[0].value;
        FB.ui({method: 'apprequests',
          message: 'My Great Request',
          to: user_ids
        }, requestCallback);
      }

More info: https://developers.facebook.com/docs/reference/dialogs/requests/



来源:https://stackoverflow.com/questions/12286817/how-to-send-facebook-apprequests-notifications-with-custom-message-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!