HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Push notification to facebook account

Is it possible to send the notification to user's facebook account if they login by their facebook account ?

Thanks

Comments

  • R_JR_J Admin

    From the Vanilla side that would be possible. But facebook needs to offer some kind of REST API for their endpoint...

  • So....I have to wait for facebook support some REST API on their side, if I want to send the notification to user's facebook account ? 😰

    Thanks.

  • R_JR_J Admin

    I might have not expressed myself correct: I do not know if it is already possible or not. If you know how to do this on the Facebook side, you can take a look on my PushbulletNotification plugin.

  • I will install your plugin to try. Thanks

  • R_JR_J Admin

    It will only help you if you are using Pushbullet and it has nothing to do with Facebook. It would just be an example how to approach writing a plugin which interacts with some api to send notifications

  • Sure. I understand that this plugin is a example for realize the notification by a POST protocol.

    I also refer the document from Facebook about notification https://developers.facebook.com/docs/games/services/appnotifications/

    It seems similar with the PushbulletNotification you provided, but there are some problem need to be solved.

    Is the user ID stored in the vanilla forum database?

    Is the access token means the Facebook APP secret key or APP ID ?

    Thanks

  • R_JR_J Admin

    Yes, the facebook id is saved in Vanilla. The facebook plugin fetches facebooks profile information and then calls

           Gdn::userModel()->saveAuthentication([
               'UserID' => $sender->User->UserID,
               'Provider' => self::PROVIDER_KEY,
               'UniqueID' => $profile['id']]);
    


    The UserModel->saveAuthentication builds the following sql

    $sql = "insert {$px}UserAuthentication (ForeignUserKey, ProviderKey, UserID) values ($uID, $provider, $userID) on duplicate key update UserID = $userID";
    


    So the facebook id is in table GDN_UserAuthentication, column ForeignUserKey, where UserID is the Vanilla user id of the user who shall receive the notification and ProviderKey is FacebookPlugin::PROVIDER_KEY (not sure if the provider key can be accessed like that)

    On the facebooks apps access token side, I'm not that sure. Vanillas facebook plugin also creates an access token and maybe that one is meant? It's saved in the User table, column Attributes. You should access it like that:

    // assuming you have Vanillas user ID of the user to be notified in the variable $userID
    $user = Gdn::userModel()->getID($userID);
    $accessToken = $user->Attributes[FacebookPlugin::PROVIDER_KEY.'.AccessToken'];
    

    Again, I'm not sure about that "FacebookPlugin::PROVIDER_KEY" part.

    I would try it with this credentials, but I really don't have a clue about which access token the facebook documentation is talking about.

  • I got a information to talk about the access token from Facebook https://developers.facebook.com/docs/facebook-login/access-tokens/?locale=en_US#apptokens

    Compare with the previous comment mentioned :

    "Apps can generate notifications by issuing a HTTP POST request to the /userid/notifications Graph API, with an app accesstoken. You may find more details by referring to the Graph API notifications edge."

    The access token should be app access token.

    Is that correct in my understanding ?

  • Hi @R_J

    Do you have any idea about this access token ?

    thanks.

Sign In or Register to comment.