Thursday, November 8, 2012

Facebook graph api

Sample application created using the following dll's

Get your blessing word https://christopher.azurewebsites.net/ 

You can create a facebook application simply using these dll's.
download these dll's from the following links.
FBHelper.dll
NewtonSoft JSON

then you need to create a facebook app using the link fbapp and then navigate to create facebook app page and do the processings and the get the appID and appsecret.

then


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Newtonsoft.Json;
using FBHelper;
using FBHelper.Entity;
using System.IO;


namespace FacebookApp
{
    public partial class AppPage : System.Web.UI.Page
    {
        FB fbApp = new FB();

        protected void Page_Load(object sender, EventArgs e)
        {
            string imageUrl = Server.MapPath(@"/image/Hydrangeas.jpg");

            fbApp.AppID = "YOUR_APP_ID";
            fbApp.AppSecret = "YOUR_APP_SECRET";
            fbApp.RedirectURL = "http://localhost:51337/AppPage.aspx";
            string code = Request.QueryString["code"] as string;
            string error = Request.QueryString["error_description"] as string;

            if (string.IsNullOrEmpty(error))
            {
                if (string.IsNullOrEmpty(code))
                {
                    Response.Redirect(fbApp.CodeRequestURL);
                }
                else
                {
                    fbApp.Code = code;
                    fbApp.GetAccessToken();
                    string token = fbApp.AccessToken;
                    FBUser user = fbApp.GetMe();
                    List<FBUser> friends = fbApp.GetMyFriends();
                    List<Photo> pics = fbApp.GetMyPhotos();

                    string statusID = fbApp.UpdateStatus(user.ID, "hiiiii");
                    string album = fbApp.CreateAlbum(user.ID, "Sample", "new sample");
                    List<Album> alb = fbApp.GetAllAlbumDetails();
                    List<Likes> like = fbApp.GetAllLikesByMe();

                    fbApp.UploadPhoto("Sample Image", imageUrl);
                    fbApp.UploadPhotoToAnAlbum(album, "Hiiiiii", imageUrl);
                }
            }
        }
    }
}




No comments:

Post a Comment