Posting Image and Text in Facebook

In this article we will explain how to Post images and text messages on Facebook through the Facebook app, you have to follow these steps:

Step-1:

Create a new ASP.Net Solution and Add a Default.aspx page. Then copy its localhost URL.

Step-2:

Log in to your Facebook account. Then Open this given link https://developers.facebook.com/apps.

Step-3:

Click on “Add a new App”. Then a popup window will open.

asp.net, asp net,Facebook,Share Post on Facebook, Share Post in Facebook,mvc, asp net mvc, Post images in Facebook Timeline, Share Post in Facebook Timeline using c# asp.net, mvc, Facebook App,facebook  Developers, post text and images in Facebook, how to post  or share text and images in Facebook timeline using asp.net mvc, how to use facebook app, create facebook app, how to create facebook app, Share post text and images through facebook app using asp.net mvc, how to share post in facebook using asp.net,how to share post in facebook using asp.net mvc c#

Step-4:

In this popup, write your Application Name in Display Name and Select Category. Then Click on Create App ID. Then it will ask for a security check. Then Submit it.

asp.net, asp net,Facebook,Share Post on Facebook, Share Post in Facebook,mvc, asp net mvc, Post images in Facebook Timeline, Share Post in Facebook Timeline using c# asp.net, mvc, Facebook App,facebook  Developers, post text and images in Facebook, how to post  or share text and images in Facebook timeline using asp.net mvc, how to use facebook app, create facebook app, how to create facebook app, Share post text and images through facebook app using asp.net mvc, how to share post in facebook using asp.net,how to share post in facebook using asp.net mvc c#

Step-5:

After Submit a developer Application window will open. And go to the settings page.

asp.net, asp net,Facebook,Share Post on Facebook, Share Post in Facebook,mvc, asp net mvc, Post images in Facebook Timeline, Share Post in Facebook Timeline using c# asp.net, mvc, Facebook App,facebook  Developers, post text and images in Facebook, how to post  or share text and images in Facebook timeline using asp.net mvc, how to use facebook app, create facebook app, how to create facebook app, Share post text and images through facebook app using asp.net mvc, how to share post in facebook using asp.net,how to share post in facebook using asp.net mvc c#

Then Copy the App ID and App Secret for your solution.

Step-6:

Then click on Add Platform and choose the website. And set your website or localhost url.

asp.net, asp net,Facebook,Share Post on Facebook, Share Post in Facebook,mvc, asp net mvc, Post images in Facebook Timeline, Share Post in Facebook Timeline using c# asp.net, mvc, Facebook App,facebook  Developers, post text and images in Facebook, how to post  or share text and images in Facebook timeline using asp.net mvc, how to use facebook app, create facebook app, how to create facebook app, Share post text and images through facebook app using asp.net mvc, how to share post in facebook using asp.net,how to share post in facebook using asp.net mvc c#

Step-7:

Go to your menu bar option, select Add Product and then choose the Facebook login option.

asp.net, asp net,Facebook,Share Post on Facebook, Share Post in Facebook,mvc, asp net mvc, Post images in Facebook Timeline, Share Post in Facebook Timeline using c# asp.net, mvc, Facebook App,facebook  Developers, post text and images in Facebook, how to post  or share text and images in Facebook timeline using asp.net mvc, how to use facebook app, create facebook app, how to create facebook app, Share post text and images through facebook app using asp.net mvc, how to share post in facebook using asp.net,how to share post in facebook using asp.net mvc c#

Step-8:

Now go to the Facebook Login Page. And give your website URL or localhost URL in Valid OAuth redirect URIs. Then click on save changes

asp.net, asp net,Facebook,Share Post on Facebook, Share Post in Facebook,mvc, asp net mvc, Post images in Facebook Timeline, Share Post in Facebook Timeline using c# asp.net, mvc, Facebook App,facebook  Developers, post text and images in Facebook, how to post  or share text and images in Facebook timeline using asp.net mvc, how to use facebook app, create facebook app, how to create facebook app, Share post text and images through facebook app using asp.net mvc, how to share post in facebook using asp.net,how to share post in facebook using asp.net mvc c#


Step-9:

Then go to the App Review page. Then set your created App public true.

asp.net, asp net,Facebook,Share Post on Facebook, Share Post in Facebook,mvc, asp net mvc, Post images in Facebook Timeline, Share Post in Facebook Timeline using c# asp.net, mvc, Facebook App,facebook  Developers, post text and images in Facebook, how to post  or share text and images in Facebook timeline using asp.net mvc, how to use facebook app, create facebook app, how to create facebook app, Share post text and images through facebook app using asp.net mvc, how to share post in facebook using asp.net,how to share post in facebook using asp.net mvc c#




Then click on start a submission button.

asp.net, asp net,Facebook,Share Post on Facebook, Share Post in Facebook,mvc, asp net mvc, Post images in Facebook Timeline, Share Post in Facebook Timeline using c# asp.net, mvc, Facebook App,facebook  Developers, post text and images in Facebook, how to post  or share text and images in Facebook timeline using asp.net mvc, how to use facebook app, create facebook app, how to create facebook app, Share post text and images through facebook app using asp.net mvc, how to share post in facebook using asp.net,how to share post in facebook using asp.net mvc c#


Then select all items from this submission page and click add items.

asp.net, asp net,Facebook,Share Post on Facebook, Share Post in Facebook,mvc, asp net mvc, Post images in Facebook Timeline, Share Post in Facebook Timeline using c# asp.net, mvc, Facebook App,facebook  Developers, post text and images in Facebook, how to post  or share text and images in Facebook timeline using asp.net mvc, how to use facebook app, create facebook app, how to create facebook app, Share post text and images through facebook app using asp.net mvc, how to share post in facebook using asp.net,how to share post in facebook using asp.net mvc c#

Step-10:

Now you go to your ASP.Net solution. And an “aspsnippets.facebookapi.dll” file in your solution reference.

Step-11:

Go to your Default.aspx page and add controls in your design page.

<asp:FileUpload ID="FileUpload1" runat="server" />
    <br />
    <br />
    <asp:TextBox ID="txtMessage" runat="server" TextMode = "MultiLine"></asp:TextBox>
    <hr />
    <asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick = "UploadPhoto" />
 

Step-12:

Write this below coding in your “Default.aspx.cs” page:
1. Add Namespace:
using ASPSnippets.FaceBookAPI;

2. Write this below coding in the “Page_Load” event.  

        FaceBookConnect.API_Key
= "404417453247103";
        FaceBookConnect.API_Secret = "03c91fd2103207adb84508249e6848dd";
        if (!IsPostBack)
        {
            HttpPostedFile updfile=(HttpPostedFile)Session["File"];
            string code = Request.QueryString["code"];
            if (!string.IsNullOrEmpty(code))
            {
                if (updfile.FileName != "")
                {
                    FaceBookConnect.PostFile(code, "me/photos", updfile, Session["Message"].ToString());
                    Session["File"] = null;
                    Session["Message"] = null;
                }
                else
                {
                    Dictionary<string, string> data = new Dictionary<string, string>();
                    data.Add("message", Session["Message"].ToString());
                    FaceBookConnect.Post(code, "me/feed", data);
                    Session["File"] = null;
                    Session["Message"] = null;
                }
            }
        }
   

3. Write these code in button click event:
        Session["File"] =
FileUpload1.PostedFile!=null?FileUpload1.PostedFile:null;
        Session["Message"] = txtMessage.Text;
        FaceBookConnect.Authorize("user_photos,publish_actions", Request.Url.AbsoluteUri.Split('?')[0]);
        ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Image has been shared.');", true);
   

Post a Comment

0 Comments