Omi
Omi

Reputation: 447

Contents Posted on Facebook Page not visible?

I am trying to post on my Facebook page using c# and Facebook sdk. I am able to post the contents on my Facebook page but it is not properly visible to others. Even the admin of the page can view only the heading of the post but can not see the picture or the content of that post. But the admin of the page can see the contents of the post by clicking on ">" this sign beside post to page. Please guide me why this is happening and how can I resolve this.

protected void Page_Load(object sender, EventArgs e)
{
    CheckAuthorization();
}

private void CheckAuthorization()
{
    string app_id = "My App ID";
    string app_secret = "My App Secret";
    string scope = "publish_stream, publish_actions";
    if (Request["code"] == null)
    {
        Response.Redirect(string.Format("https://graph.facebook.com/oauth/authorize?client_id={0}&redirect_uri={1}&scope={2}", app_id, Request.Url.AbsoluteUri, scope));
    }
    else
    {
        Dictionary<string, string> tokens = new Dictionary<string, string>();
        string url = string.Format("https://graph.facebook.com/oauth/access_token?client_id={0}&redirect_uri={1}&scope={2}&code={3}&client_secret={4}",app_id,Request.Url.AbsoluteUri,scope,Request["code"].ToString(),app_secret);
        HttpWebRequest request = System.Net.WebRequest.Create(url) as HttpWebRequest;

        using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
        {
            StreamReader reader = new StreamReader(response.GetResponseStream());

            string vals = reader.ReadToEnd();

            foreach (string token in vals.Split('&'))
            {
                tokens.Add(token.Substring(0, token.IndexOf("=")), token.Substring(token.IndexOf("=") + 1, token.Length - token.IndexOf("=") - 1));
            }
        }
        string access_token = tokens["access_token"];



        var client = new FacebookClient(access_token);

        dynamic parameters = new ExpandoObject();
        parameters.message = "Hello This Is My First Post To Facebook";
        parameters.link = "http://www.google.com";
        parameters.picture = "http://www.mywebsite.com/picture/welcome.jpg";
        parameters.name = "Hello Users We welcome you all";
        parameters.caption = "Posted By Ashish";



        client.Post("/My Facebook Page ID/feed", parameters);
    }
}

Please guide me where I am doing wrong since I am trying this for the first time after following certain posts on several websites.

Upvotes: 0

Views: 171

Answers (2)

KADEM Mohammed
KADEM Mohammed

Reputation: 1650

I just want to add that sometimes your app is in MODE : developer so everything you do is visible only to the developers, it is actually the problem i had, So you need to go to your application Dashboard and look for something like "Review" [i hate giving exact paths because Facebook changes everything every once in a while], and look for something like : Your app is in development and unavailable to the public, put it to public

Upvotes: 0

Sahil Mittal
Sahil Mittal

Reputation: 20753

You are using the user access token to post a feed to the page. So, the feeds are posted on behalf the user (not the page), which are visible as summary on the timeline.

If you post the feed on behalf of page admin itself (so that the post is visible normally on the timeline), you need to use the page access token with publish_actions permissions.

And to get the page access token you need to query: /<page-id>?fields=access_token using the normal user token with manage_pages permission.

Upvotes: 1

Related Questions