This project is read-only.

Migration to facebook graph 2.1

Jan 28, 2015 at 9:12 AM
Edited Jan 28, 2015 at 9:19 AM
Programing Language :
Toolkit used:4.0
targeted computer beacon Graph Toolkit:5.1 (latest packages installed from
targeted computer beacon Json Toolkit:4.3.832 (latest packages installed from

if anyone can please help use do the migration of our application to the new toolkit. we have tried doing a research to do it. but unfortunately we didn't find any example, the documentation doesn't cover everything can you please advice

below is my code that i need to convert:

Imports ComputerBeacon.Facebook
Imports ComputerBeacon.Json
Imports ComputerBeacon.Facebook.Server
Imports ComputerBeacon.Facebook.Graph
Imports ComputerBeacon.Facebook.Graph.Post

Partial Public Class _default
    Inherits System.Web.UI.Page
    Private Pagecontext As PageTabContext 'Error 3
    Public InviteMsg As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not IsPostBack Then
            'the Page Tab does not require authorization
            Pagecontext = PageTabContext.FromConfig(System.Web.HttpContext.Current)

            'Dim loginSettings = New LoginSettings()
            'loginSettings = New LoginSettings("320225998035765", "10b1988face8e6329869a7ae3d39d9a7")

            'Pagecontext = New PageTabContext(HttpContext, New LoginSettings())

            If Pagecontext.PageData Is Nothing Or Pagecontext.PageData.JsonData Is Nothing Then
                Pagecontext.IframeRedirect(ConfigurationManager.AppSettings("FBPageTabLink"), True)
            End If

            If Pagecontext.HasLikedPage Then

                'check if the user Authorized the application
                'loginSettings.Permissions = New String() {"publish_actions", "email" ,"user_birthday","user_hometown","user_location"}

                Pagecontext.RequireLogin = True

                If Pagecontext.Session Is Nothing Then Pagecontext.RedirectToFacebookAuthorization()

            End If

            ViewState("PageTabContext") = Pagecontext.ToSerializedString()

            Pagecontext = PageTabContext.FromSerializedString(System.Web.HttpContext.Current, TryCast(ViewState("PageTabContext"), String))
        End If

    End Sub
    Private Sub participateNow()
        Dim u As New Graph.User("me", Pagecontext.AccessToken)

        Dim F1 = IIf(u.Username Is Nothing, "", u.Username)
        Dim F6 = IIf(u.Birthday Is Nothing, DBNull.Value, u.Birthday)
        Dim F11 = IIf(u.PoliticalView Is Nothing, "", u.PoliticalView)
        Dim F15 = IIf(u.UpdatedTime Is Nothing, "", u.UpdatedTime)

        Dim F16 = u.GetFriends(u.Id, Pagecontext.AccessToken).Count

    End Sub
    Private Sub Post2Wall()

        Dim CaptionTitle As String = "..."
        Dim request As CreatePostRequest = New CreatePostRequest("me", CaptionTitle, Pagecontext.AccessToken)
        Dim action As PostAction = New PostAction()
        action.Name = "App by ..."
        action.Url = "https://..."

        request.PictureUrl = "https://..."
        request.Message = ""
        request.Action = action

        Dim x As New LinkAttachment
        x.Name = "..."
        x.Url = ConfigurationManager.AppSettings("FBPageTabLink")
        x.Caption = "..."
        x.Description = "..."
        request.Link = x

        Catch ex As Exception
        End Try
    End Sub

End Class
Jan 30, 2015 at 4:48 AM
A close equivalent in FGT 5 would be:
    public partial class _Default : Page {
        string accessToken;

        protected void Page_Load(object sender, EventArgs e) {
            if (!Page.IsPostBack) {
                var loginSettings = new LoginSettings();
                loginSettings.Permissions = new[] { "publish_actions", "email", "user_birthday", "user_hometown", "user_location" };
                var fbContext = new PageTabContext(new HttpContextWrapper(this.Context), loginSettings);

                if (fbContext.UserId == null) {
                    //user has not authorized. Redirect.

                    var finalUrl = string.Format("{0}?sk=app_{1}", fbContext.PageId, loginSettings.AppId);
                } else {
                    var u = new ComputerBeacon.Facebook.Graph.User("me", fbContext.AccessToken);
                    var sb = new StringBuilder();
                    sb.Append("Birthday: ").Append(["birthday"]).Append("<br />");
                    sb.Append("Political view: ").Append(u.Political).Append("<br />");
                    label1.Text = sb.ToString();

                    //save token to ViewState
                    ViewState["accessToken"] = accessToken = fbContext.AccessToken;
            } else accessToken = ViewState["accessToken"] as string;

        protected void btn1_Click(object sender, EventArgs e) {
            var dict = new Dictionary<string, string>();
            dict["access_token"] = accessToken;
            dict["message"] = "Hello world";
            dict["link"] = "";
            dict["caption"] = "Computer Beacon";
            dict["description"] = "Description";

            var actions = new JsonObject();
            actions["name"] = "Try me!";
            actions["link"] = "";
            dict["actions"] = actions.ToString();

            var jo = ComputerBeacon.Facebook.Api.Post("me/feed", dict);
            label1.Text = jo.ToString();
Jan 30, 2015 at 7:54 AM
@Kayson we are really thankful for your time and support

kindly note that we are still facing some issues when trying to implement your provided code

The below message is being shown when trying to call some of the new functions found in your code error: reference required to assembly 'computerBeacon.json version = 4.2.795.1747

in your code there's a class in which i can't find calling "InlineAssignHelper"

Also please i need a conversion for the below code:
Dim request As CreatePostRequest = New CreatePostRequest("me", CaptionTitle, AccessToken)
Dim action As PostAction = New PostAction()
action.Name = "..."
action.Url = "..."
Dim x As New LinkAttachment
Jan 30, 2015 at 1:33 PM
There is no class which I used called "InlineAssignHelper".

That portion of the code is already contained in the sample code.