facebook create_event 在我的应用程序墙上而不是用户墙上发布

发布于 2024-10-12 14:55:36 字数 1558 浏览 0 评论 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 中返回的“代码”请求访问令牌 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);

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

i'm attempting to provide a facility on my site that allows a user to create a facebook event for their booking.

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

now im doing the correct process:

1) first getting authorisation from the user
https://graph.facebook.com/oauth/authorize?client_id=APP_ID&redirect_uri=http://urlimredirectingto.comtype=web_server

2) requesting for an access token with the "code" that is returned in step 1
https://graph.facebook.com/oauth/access_token

3) using the access_token to create the event ...

   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);

but the event is posted on my app's wall, not the user's wall. It shouldn't have anything to do with the authentication/access_token elements because i use the same process to post on the user's wall. (http://developers.facebook.com/docs/reference/api/status/) and that works just fine.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

海夕 2024-10-19 14:55:36

我带着一个解决方案回来了,经过一周使用 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 的 C# SDK for Facebook - dld 的最新版本(2011 年 8 月 - v5.2.1)。

祝你好运!

I came back with a solution, after a week of working at many features with Facebook SDK, it finally works!

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);
        }
    }

For events, you have to request the create_event permission.

You should use /me/events to post on your events.

I user the C# SDK for Facebook from Codeplex - last version available for dld (aug 2011 - v5.2.1).

Good luck!

傻比既视感 2024-10-19 14:55:36

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

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 的 url:
http://apps.facebook.com/MY_APP_NAME_OR_ID

查看活动的扩展权限并在 文档


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

在用户墙上发布时,远程服务器返回错误:(403) 禁止
话虽这么说,我也同意这个问题。

I don;t see in your request for Authorization any permission.. base permissions are not enough to do the postings.
i used:

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

This is in the context of a canvas app. where MY_APP_URL is the url from facebook of the app:
http://apps.facebook.com/MY_APP_NAME_OR_ID

See extended permissions for events and check event's page in documentation


[EDIT] - I came back, sorry, now i did a test, and indeed, it works for me, but only of i post on my app's wall; even if i provided the 'user_events' permission i get this error:

The remote server returned an error: (403) Forbidden when posting on a user's wall.
This being said, i also subscribe to this question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文