Is facebook user to user request possible with W8/WP8 c# sdk?

后端 未结 1 1093
再見小時候
再見小時候 2020-12-07 03:40

I\'m trying to get my mobile game to invite friends from facebook but I\'m unable to. I\'m using Facebook c# SDK for Windows 8 (hopefully porting when ready to WP8, Android

相关标签:
1条回答
  • 2020-12-07 04:11

    Yes it is possible. Unfortunately, you cannot do it via the SDK since Facebook doesnt allow you to send requests programatically. It has to be done through the dialog request box/popup.

    So, make sure the user is logged in before trying the following solution. After you get the facebook access token by using the LoginAsync method, follow these steps.

    1. Create a WebBrowser control in your xaml with script enabled.

    <phone:WebBrowser Visibility="Collapsed" IsScriptEnabled="True" Name="FbBrowser"></phone:WebBrowser>

    1. Now in your code behind, create a string with the facebook ids of the users you want to invite in CSV format like "id1,id2,id3".

    2. Navigate the web browser to the following page and subscribe to the navigating event: "https://m.facebook.com/dialog/apprequests?" + "message=your_message&app_id=" + "your_facebook_appid" + "&redirect_uri=https://m.facebook.com&to=" + user_facebook_ids_CSV + "&sdk=2&display=touch"

    FbBrowser.Visibility = Visibility.Visible; FbBrowser.Navigating += FbBrowser_Navigating; FbBrowser.Navigate(url1);

    1. You can handle the success and failure response of the webpage in the navigating event.

    private void FbBrowser_Navigating(object sender, NavigatingEventArgs e) { if (e.Uri.ToString().StartsWith("https://m.facebook.com/?error_code") || e.Uri.ToString().StartsWith("https://m.facebook.com/?request")) { FbBrowser.Visibility = Visibility.Collapsed; FbBrowser.Navigate(new Uri("about:blank"));
    } }

    0 讨论(0)
提交回复
热议问题