首页 文章

我在我的应用程序's wall not the user'的墙上发布了facebook create_event帖子

提问于
浏览
0

我试图在我的网站上提供一个设施,允许用户为他们的预订创建一个facebook活动 .

http://developers.facebook.com/docs/reference/api/event/

现在我正在做正确的过程:

1)首先获得用户的授权https://graph.facebook.com/oauth/authorize?client_id=APP_ID&redirect_uri=http://urlimredirectingto.comtype=web_server

2)使用在步骤1中返回的"code"请求访问令牌https://graph.facebook.com/oauth/access_token

3)使用access_token创建事件...

string facebookCreateUri = string.Format("https://graph.facebook.com/{0}/events", loggedInMember.FacebookUID);

  var formData = new HttpUrlEncodedForm() 
  {
   {"access_token", accessToken},
   {"owner", loggedInMember.FacebookUID},
   {"description", "nice event that should be on the owners wall"},
   {"name", "event on the users wall"},
   {"start_time", "1272718027"},
   {"end_time", "1272718027"},
   {"location", "rochester"},
   {"privacy","OPEN"}       
  };

  HttpContent content = HttpContent.Create(formData);
  HttpClient client = new HttpClient();

  var response = client.Post(facebookCreateUri, "application/x-www-form-urlencoded", content);

但事件发布在我的应用程序的墙上,而不是用户的墙上 . 它不应该与authentication / access_token元素有任何关系,因为我使用相同的过程在用户的墙上发布 . (http://developers.facebook.com/docs/reference/api/status/)并且工作得很好 .

2 回答

  • 1

    我带着一个解决方案回来了,经过一周的Facebook SDK功能,它终于有效了!

    protected void onPostEvent(object sender, EventArgs e)
        {
            if (CanvasAuthorizer.Authorize())
            {
                var fb = new FacebookWebClient(CanvasAuthorizer.FacebookWebRequest);
    
                dynamic parameters = new ExpandoObject();
                parameters.description = txtEvDett.Text;
                parameters.name = txtEvName.Text;
                parameters.start_time = DateTime.Now.ToString("yyyyMMdd");
                parameters.end_time = DateTime.Now.AddDays(1).ToString("yyyyMMdd");
                parameters.access_token = CanvasAuthorizer.FacebookWebRequest.AccessToken;
    
                dynamic eventDet = fb.Post("me/events", parameters);
    
                litEvent.Text = String.Format("You have created the event with ID: {0}", eventDet.id);
                lnkEvent.Visible = true;
                lnkEvent.NavigateUrl = String.Format("http://www.facebook.com/event.php?eid={0}", eventDet.id);
            }
        }
    

    对于事件,您必须请求 create_event 权限 .

    您应该使用 /me/events 发布您的活动 .

    我从Codeplex使用Facebook的C#SDK - 最新版本可用于dld(2011年8月 - v5.2.1) .

    祝好运!

  • 1

    我没有在您的授权请求中看到任何权限..基本权限不足以进行发布 . 我用了:

    https://www.facebook.com/dialog/permissions.request?app_id=MY_APP_ID&next=MY_APP_URL&display=page&response_type=code&canvas=1&perms=publish_stream,user_about_me,email
    

    这是在画布应用程序的上下文中 . 其中MY_APP_URL是应用程序的Facebook的网址: http://apps.facebook.com/MY_APP_NAME_OR_ID

    查看事件的扩展权限并检查documentation中的事件页面


    [编辑] - 我回来了,对不起,现在我做了一个测试,确实,它适用于我,但只有我在我的应用程序的墙上发布;即使我提供'user_events'权限我也会收到此错误:

    The remote server returned an error: (403) Forbidden 在用户的墙上发布时 . 话虽如此,我也赞同这个问题 .

相关问题