View on Github Documentation Sample Tutorial Getting Started

Windows SDK for Facebook

Home | Auth | Dialogs |Graph API

Dialogs

 

Table of Contents

 

Feed Dialog

The feed dialog allows the app to specify a title, link, and description for a post to the user’s feed. The user can enter a custom message before posting it to Facebook.

using System;
using Windows.Foundation.Collections;
using winsdkfb;

namespace SampleCode
{
    public static partial class SampleFunc
    {
        static async void ShowFeedDialog()
        {
            // Get active session
            FBSession sess = FBSession.ActiveSession;

            if (sess.LoggedIn)
            {
                // Set caption, link and description parameters
                PropertySet parameters = new PropertySet();
                parameters.Add("title", "Microsoft");
                parameters.Add("link", "https://www.microsoft.com/en-us/default.aspx");
                parameters.Add("description", "Microsoft home page");
                //Display feed dialog
                FBResult fbresult = await sess.ShowFeedDialogAsync(parameters);
                if (fbresult.Succeeded)
                {
                    //Posting succeeded
                }
                else
                {
                    //Posting failed
                }
            }
        }
    }
}
#include "pch.h"

using namespace Windows::Foundation::Collections;
using namespace Platform;
using namespace concurrency;
using namespace winsdkfb;
using namespace winsdkfb::Graph;

namespace SampleCode
{
    void ShowFeedDialog()
    {
        // Get active session
        FBSession^ sess = FBSession::ActiveSession;
        if (sess->LoggedIn)
        {
            // Set caption, link and description parameters
            PropertySet^ parameters = ref new PropertySet();
            parameters->Insert(L"caption", L"Microsoft");
            parameters->Insert(L"link", L"https://www.microsoft.com/en-us/default.aspx");
            parameters->Insert(L"description", L"Microsoft home page");
            // Display feed dialog
            create_task(sess->ShowFeedDialogAsync(parameters)).then([=](FBResult^ result)
            {
                if (result->Succeeded)
                {
                    // Posting succeeded
                }
                else
                {
                    // Posting failed
                }
            });
        }
    }
}

Request Dialog

The user can invite his/her Facebook friends to the app through the request dialog. Note that your app must be set to type ‘Game’ when registering with Facebook in order for the request dialog to work.

using System;
using Windows.Foundation.Collections;
using winsdkfb;

namespace SampleCode
{
    public static partial class SampleFunc
    {
        static async void ShowRequestDialog()
        {
            // Get active session
            FBSession sess = FBSession.ActiveSession;

            if (sess.LoggedIn)
            {
                // Set parameters
                PropertySet parameters = new PropertySet();
                // Set message
                parameters.Add("message", "Try this sample.");
                // Display feed dialog
                FBResult fbresult = await sess.ShowRequestsDialogAsync(parameters);
                if (fbresult.Succeeded)
                {
                    // Requests sent
                }
                else
                {
                    // Sending requests failed
                }
            }
        }
    }
}
#include "pch.h"

using namespace Windows::Foundation::Collections;
using namespace Platform;
using namespace concurrency;
using namespace winsdkfb;
using namespace winsdkfb::Graph;

namespace SampleCode
{
    void ShowRequestDialog()
    {
        // Get active session
        FBSession^ sess = FBSession::ActiveSession;
        if (sess->LoggedIn)
        {
            // Set parameters
            PropertySet^ parameters = ref new PropertySet();
            // Set message
            parameters->Insert(L"message", L"Try this sample.");
            // Display requests dialog
            create_task(sess->ShowRequestsDialogAsync(parameters)).then([=](FBResult^ result)
            {
                if (result->Succeeded)
                {
                    // Requests sent
                }
                else
                {
                    // Sending requests failed
                }
            });
        }
    }
}

Send Dialog

Using the send dialog, a user can send private messages to any of his/her facebook friends with a predetermined link specified.

using System;
using Windows.Foundation.Collections;
using winsdkfb;

namespace SampleCode
{
    public static partial class SampleFunc
    {
        static async void ShowSendDialog()
        {
            //Get active session
            FBSession sess = FBSession.ActiveSession;

            if (sess.LoggedIn)
            {
                PropertySet parameters = new PropertySet();
                parameters.Add("link", "https://www.microsoft.com/en-us/default.aspx");
                //Display send dialog
                FBResult fbresult = await sess.ShowSendDialogAsync(parameters);
                if (fbresult.Succeeded)
                {
                    //message successfully sent
                }
                else
                {
                    //message failed to send
                }
            }
        }
    }
}
#include "pch.h"

using namespace Windows::Foundation::Collections;
using namespace Platform;
using namespace concurrency;
using namespace winsdkfb;
using namespace winsdkfb::Graph;

namespace SampleCode
{
    void ShowSendDialog()
    {
        //Get active session
        FBSession^ sess = FBSession::ActiveSession;
        if (sess->LoggedIn)
        {
            PropertySet^ parameters = ref new PropertySet();
            parameters->Insert(L"link", L"https://www.microsoft.com/en-us/default.aspx");
            //Display send dialog
            create_task(sess->ShowSendDialogAsync(parameters)).then([=](FBResult^ result)
            {
                if (result->Succeeded)
                {
                    //message successfully sent
                }
                else
                {
                    //message failed to send
                }
            });
        }
    }
}