Dialogs
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.
#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.
#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.
#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
}
});
}
}
}