Manage Facebook Page tab apps via Open Graph API?

后端 未结 3 811
野的像风
野的像风 2021-02-02 03:47

I have been investigating the Facebook Open Graph API. There is a \"manage pages\" extended permission which allows publishing to a user\'s Facebook Page news feed/wall via \"im

3条回答
  •  执念已碎
    2021-02-02 04:01

    There's a way to do it via the API. We finally got it to work, after many hours of sweat and tears :)

    You can add a tab to a page without leaving your app. Here's a snippet of code that we used for that. We get a list of pages that a user manages, show them in a drop down and ask them to select what page they want to add our "my agent profile" tab to.

    And the final product looks something like this - http://www.facebook.com/pages/Jennifer-Anderson-Real-Estate-Agent/185071901564573?sk=app_253956901293839

    protected void btnAddTab_Click(object sender, EventArgs e)
    {
        if (ddlPage2.SelectedIndex >= 0)
        {
            FaceBookPages page = FaceBookPages.LookupByPageID(long.Parse(ddlPage2.SelectedValue));
            if (page == null)
                throw new NPlaySysException("FaceBookPages is null.");
    
            AnalyticLog log = new AnalyticLog();
            log.EventID = FBCommon.Events.AddAgentAppTabID;
            log.UserID = UserID;
            log.EventTime = DateTime.Now;
            log.Update();
    
            string result = FacebookSvc.AddTab(Web.AgentAppID, "me", page.AccessToken);
            if (result.Equals("true"))
            {
                FaceBookPages.UpdateAgentProfileAdded(page.PageID, true);
                List notTabbedPages = FaceBookPages.LookupAgentProfileNotAddedByUserID(UserID);
    
                imgStep3.ImageUrl = StepDoneImagePath;
                divStep3.Attributes["class"] = StepDoneCssClass;
                phStep3.Visible = false;
                Step3Done = true;
                btnCloseStep3.Visible = false;
    
                if (notTabbedPages.Count > 0)
                    btnEditStep3.Visible = true;
                else
                    btnEditStep3.Visible = false;
            }
            else
            {
                lblErrorAddTab.Text = "Failed to add your profile to page.";
                Web.EmailError(string.Format("FacebookSvc.AddTab Failed. result={0}
    UserID={1}
    PageID={2}", result, UserID, page.PageID)); } } }

提交回复
热议问题