【问题标题】:facebook create_event posts on my app's wall not the user's wallfacebook create_event 在我的应用程序墙上而不是用户的墙上发帖
【发布时间】:2011-06-11 16:41:41
【问题描述】:

我正在尝试在我的网站上提供一个工具,允许用户为他们的预订创建 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);

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

【问题讨论】:

    标签: facebook-graph-api


    【解决方案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)。

    祝你好运!

    【讨论】:

      【解决方案2】:

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

      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

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


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

      远程服务器在用户墙上发帖时返回错误:(403) Forbidden。 话虽如此,我也订阅了这个问题。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多