Facebook Stream Publish to Friends for ASP.NET

Facebook Stream Publish Friend List control is used to publish stories on the friends' walls simply by selecting a friend from the list and clicking one button. Publishing a story on friend's wall is much more effective if somebody wants to inform this person about something. Story is not only sent to user’s friends, but also to friends of user’s friends. The control enables you to create a list of selected friends from which a user can choose to whose wall he will publish a story. Facebook Stream Publish to Friends is frequently used in Facebook gift applications to leave info about sent gift to friend's wall, and so ensure that he/she will see it. Is it also used in games, for example, to send info about achievements, to send request for something from a friend, how they play the same game, or to send to friend info that user just got something that can be useful to this particular friend. Because of limitation in Facebook API, and also because of Facebook terms and conditions, it is not possible to publish something on multiple friends' walls at once. User has to choose friends one by one from the list, and publish to their walls for each of them separately. The control is available in C# and VB.NET programming languages, as part of Facebook ASP.NET (C# and VB.NET) Control library.



facebook stream publish friends




Usage Examples:

Following example shows usage of Facebook Stream Publish Friends List ASP.NET control, from registration and insertion in ASPX file, to implementation of an event handler and setting of dynamic properties in the code behind. Implementation is given in C# and VB.NET programming languages.

Examples of ASPX files show only the required code for registration and integration of ASP.NET control in a web page. To see all requirements for registered components, including JavaScript, CSS style and header setting, please look at the manual for page requirements. For following examples, all page requirements are placed in ASP.NET master page. Important parts for registration and integration of Facebook Stream Publish control inside ASP.NET page are highlighted. Note that the control uses its own JavaScript which is required to be included in every page where the control is used.

Code behind shows how to set a friend list by getting first 4 user's friends, using Facebook C# SDK with Graph API method. How to set media type, story properties, action links, and event handlers are not shown here because it is already shown for Stream Publish Popup control.


Integration in ASPX file:
 <%@ Page MasterPageFile="~/Master.Master" AutoEventWireup="true" Inherits="FVK_Demo.StreamPublish" %>
 <%@ Register TagPrefix="fvk" TagName="streampublishfriends" Src="~/FVK/StreamPublishFriendList.ascx" %>
 <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>Facebook Stream Publish Control for ASP.NET</title>
    <meta name="description" content="ASP.NET Stream Publish popup control for Facebook Connect web sites." />
    <script type="text/javascript" src="/FVK/JavaScript/JSON.js"></script>
    <script type="text/javascript" src="/FVK/JavaScript/StreamPublishPopup.js"</script>
 </asp:Content>
 <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <fvk:streampublishfriends ID="streampublish1" runat="server" 
       OnPublishCalled="OnPublishStory" OnConfirmCalled="OnConfirmStory"
       BoxText = "Make sure to inform your friend about Facebook Visual Kit by sending a story on his wall"
       MainImageUrl = "logo.png"
       Title = "Publish to friends' wall"
       PostBtnTitle = "Post"
       HideBtnTitle = "Hide"
       Name = "Facebook Visual Kit for ASP.NET"
       Href = "http://vatlab.com"
       Caption = "{*actor*} is trying Facebook Visual Kit Demo."
       Description = "Facebook Visual Kit is a set of ASP.NET user controls ..."
       UserMessage = "Try this ASP.NET library for Facebook development !!"
    />
 </asp:Content>


Code behind in C#:
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Web;
 using System.Web.UI;
 using System.Web.UI.WebControls;
 using Facebook;
 using FVK;

 namespace FVK_Demo
 {
    public partial class StreamPublish : System.Web.UI.Page
    {
       protected void Page_Load(object sender, EventArgs e)
       {
          if (!Page.IsPostBack)
          {
             // set friend list
             IList friends = new List();
             int count = 0;
             string accessToken = FvkAuth.AccessToken;
             var facebook = new FacebookClient(accessToken);
             JsonObject friendsData = (JsonObject)facebook.Api("me/friends");
             JsonArray friendsList = (JsonArray)friendsData["data"];
             foreach (JsonObject f in friendsList)
             {
                 long id = Int64.Parse((string)f["id"]);
                 string name = (string)f["name"];
                 friends.Add(new FriendData(id, name));
                 count++;
                 if (count == 4) break;
             }
             streampublish1.Friends = friends;
          }
       }
    }
 }


Code behind in VB.NET:
 Imports System.Collections.Generic
 Imports System.Linq
 Imports System.Web
 Imports System.Web.UI
 Imports System.Web.UI.WebControls
 Imports Facebook
 Imports FVK

 Namespace FVK_Demo
    Public Partial Class StreamPublish
       Inherits System.Web.UI.Page
       Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
          If Not Page.IsPostBack Then
             ' set friend list
             Dim friends As IList(Of FriendData) = New List(Of FriendData)()
             Dim count As Integer = 0
             Dim accessToken As String = FvkAuth.AccessToken
             Dim facebook = New FacebookClient(accessToken)
             Dim friendsData As JsonObject = DirectCast(facebook.Api("me/friends"), JsonObject)
             Dim friendsList As JsonArray = DirectCast(friendsData("data"), JsonArray)
             For Each f As JsonObject In friendsList
                Dim id As Long = Int64.Parse(DirectCast(f("id"), String))
                Dim name As String = DirectCast(f("name"), String)
                friends.Add(New FriendData(id, name))
	        count += 1
	        If count = 4 Then
                   Exit For
                End If
             Next
             streampublish1.Friends = friends
          End If
       End Sub
    End Class
 End Namespace




Configuration

Configuration of the Facebook Stream Publish Friend List ASP.NET control is done in ASPX page by setting properties and optional event handlers, and, as it is written in text above, the configuration is very similar to one in Facebook Stream Publish Popup ASP.NET control. If dynamic setting of properties is required, they can be also set in the code behind, for example on Page_Load method. If event handlers are used, there should be methods in the code behind to execute additional code after event handlers are executed. For Facebook Stream Publish ASP.NET control, there are mandatory and optional properties, as they are shown in following 2 tables. Mandatory properties and first 2 from optional properties are only addition in configuration in comparison to Stream Publish Popup control. All about media types, action links, and story properties can be found in tutorial about Facebook Stream Publish Popup ASP.NET control.


Mandatory Properties:
facebook login button asp.net
Property Name
Type
Description
facebook login button asp.net
BoxText
String
Text inside the box. This text has to be attractive enough to motivate user to publish on friends' wall.
facebook login button asp.net
MainImageUrl
String
Url of the image inside the box for selecting friends. It is not connected with the image that you might want to publish as content.
facebook login button asp.net
Title
String
Title of the box (text on top blue border).
facebook login button asp.net
Friends
IList
List of FriendData objects which have to be in list inside the box.


Optional Properties:
facebook login button asp.net
Property Name
Type
Description
facebook login button asp.net
PostBtnTitle
String
Title of post button. Default value is 'Post'.
facebook login button asp.net
HideBtnTitle
String
Title of hide button. Default value is 'Hide'.
facebook login button asp.net
CommandType
String
Can be set to 'link', 'button', or 'auto_open'. This means permissions popup dialog is opened by: pressing a link, button, or automatically on page load. Default value is 'button'.
facebook login button asp.net
CommandTitle
String
Text of permissions button or link. If 'auto_open' command type is used, this parameter is ignored. Default value is 'Publish'.
facebook login button asp.net
Name
String
Name of the story. If this property is linked (if Href property is set), it is important to put relevant keywords inside name to raise search engine ranking of website or Facebook application.
facebook login button asp.net
Href
String
URL of the content inside website or Facebook application where story is pointing.
facebook login button asp.net
Caption
String
Caption of the story i.e. first line below title. It is possible to include {*actor*} tag to write name of the user who published the story.
facebook login button asp.net
Description
String
Description of the story. The main text of the story. It has no limitation in length.
facebook login button asp.net
MessagePrompt
String
Message prompt is text written on top border of stream publish dialog.
facebook login button asp.net
UserMessage
String
Predefined user message. If user publishes a story, this text will be seen in news feed as he writes some comment about the story.
facebook login button asp.net
Media
IJsonSerialize
One of media objects (ImageData, VideoData, FlashData or Mp3Data). Details about initializing media types can be found in following text.
facebook login button asp.net
MediaList
IList
List of media (IJsonSerialize) objects. Facebook currently supports only Image media type.
facebook login button asp.net
Properties
IList
List of PropertyData and LinkedPropertyData objects.
facebook login button asp.net
ActionLinkList
IList
List of action links (LinkData objects).


Event Handlers:
facebook login button asp.net
Event Name
Description
facebook login button asp.net
OnPublishCalled
Has to be set to name of protected method that is implemented inside the code behind, and which will be called after Facebook Stream publish dialog is opened.
facebook login button asp.net
OnConfirmStory
Has to be set to name of protected method that is implemented inside the code behind, and which will be called after user confirms publishing of the story.
 

Customer Testimonials

"As a facebook "newby", developing a Facebook application is quite a challenge. You need to learn to Facebook concepts, the ever changing facebook APIs, working around APIs being depreciated. I found the libraries provided by Vatlab extremely helpful. Within hours I got the Facebook functions that I needed up and running. The documentation combined with the online tutorial was all that I needed.

"What also makes this product stand out in a IT world where decent product support is becoming a big issue, is the way developer of the libraries handled a question I had. The reply came very quickly and was to the point. It was a real pleasure to deal with him. I can only recommend this library and I’m sure that we will continue to see exciting new features in future."

Peter Cabus, Sr. Consultant, IT & Video Consultancy

Customer Spotlight



Vote for your favorites

Facebook development platform
Contact   |  Refund Policy   |  Privacy Policy   |  EULA