开发者

Requests Dialog in Silverlight

I'm making a si开发者_运维百科mple application with Silverlight to run on Facebook.

I already understand that to invite friends to the appliation I have to call a fb:request-form, or use the Simpler Requests.

How do I call one of these methods from Silverlight In-Browser?


You can put some javascript code (for using Simpler Requests) into your webpage and call this javascript from Silverlight app. See "CSSilverlightInBrowser" sample in Facebook C# SDK package, method LoginToFbViaJs in MainPage.xaml.cs in this sample makes login request via javascript.


I solved this by putting the facebook javascript code in the aspx file that holds my silverlight xap, and then call that code through silverlight.

This code goes into my aspx file:

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
  FB.init({
    appId  : 'APP_ID',
    status : true,
    cookie : true,
    oauth: true
  });

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

  function sendRequestViaMultiFriendSelector() {
    FB.ui({method: 'apprequests',
      message: 'My Great Request'
    }, requestCallback);
  }

  function requestCallback(response) {
    // Handle callback here
  }
</script>

You can then call it from Silverlight using this code:

        var param = new object[] { };
        HtmlPage.Window.Invoke("sendRequestViaMultiFriendSelector", param);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜