是Facebook的用户,以用户请求可能与W8 / WP8 C#SDK? [英] Is facebook user to user request possible with W8/WP8 c# sdk?

查看:253
本文介绍了是Facebook的用户,以用户请求可能与W8 / WP8 C#SDK?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让我的手机游戏,邀请Facebook上的朋友,但我不能。我使用的Facebook C#SDK的Windows 8(希望移植时准备WP8,Android和iOS),但问题是我感到困惑Facebook的API paremeters:

I'm trying to get my mobile game to invite friends from facebook but I'm unable to. I'm using Facebook c# SDK for Windows 8 (hopefully porting when ready to WP8, Android and iOS) but the problem is I'm confused about the facebook API paremeters:

这是我的code:

var fb = new FacebookClient (accessToken);
dynamic parameters = new ExpandoObject();
parameters.appId = facebookAppId;
parameters.message = "This is a test!";
parameters.to="friendID1,friendID2,...";

string request=String.Format ("/me/apprequests");
dynamic result = await fb.PostTaskAsync (request, parameters);

当我使用这个code,邮政工作正确完成,但(检查结果变量,看着脸谱)对我的用户将收到邀请。的到字段似乎被忽略和me是唯一一个在接收到请求

when I use this code, the Post task completes correctly, but (checking the result variable and looking at facebook) on the "me" user receives that invitation. The "to" field seems to be ignored and "me" is the only one receiving the request.

如果我用

string request=String.Format ("/{0}/apprequests",FRIEND_ID);

而不是/ ME / AP prequests,然后我收到以下错误:

instead of /me/apprequests, then I receive the following error:

OAuthException(#2)无法创建任何应用程序的要求,

OAuthException "(#2) Failed to create any app request",

我读过一些地方的访问令牌必须是一个应用程序令牌,但文件说,当你的服务器正在做这些请求它应该只被使用,我要的是一个用户到用户请求,不应用程式到用户请求。

I've read in some places that the access token must be an App Token, but the documentation says that it should only be used when your server is doing those requests, What I want is a user-to-user request, not an app-to-user request.

到目前为止,我已经看到了它可能通过一个对话框,要求得到它在Android和iOS,但我没有发现他们在C#SDK,所以我想手动进行AP prequest,没有运气。

So far I've seen it's possible to get it in Android and iOS via a Dialog Request, but I've not found them in the C# SDK, so I'm trying to make the apprequest manually, without luck.

是否有可能得到这个随着Windows Phone 8或Windows 8的工作?怎么样?

Is it possible to get this working with Windows Phone 8 or Windows 8? How?

谢谢,

推荐答案

是的,它是可能的。不幸的是,你无法通过,因为Facebook的犯规让您以编程方式发送请求的SDK做到这一点。它通过对话请求对话框/弹出来完成。

Yes it is possible. Unfortunately, you cannot do it via the SDK since Facebook doesnt allow you to send requests programatically. It has to be done through the dialog request box/popup.

所以,确保尝试以下解决方案之前,该​​用户已登录。通过使用LoginAsync方法来获取Facebook的访问令牌后,请按照下列步骤。

So, make sure the user is logged in before trying the following solution. After you get the facebook access token by using the LoginAsync method, follow these steps.


  1. 创建与启用脚本,您的XAML中的WebBrowser控件。

<电话:web浏览器能见度=坍塌IsScriptEnabled =真NAME =FbBrowser>< /电话:web浏览器>


  1. 现在在你的code背后,创建要在CSV格式如ID1,ID2,ID3邀请用户的Facebook ID的字符串。

  1. Now in your code behind, create a string with the facebook ids of the users you want to invite in CSV format like "id1,id2,id3".

浏览网页浏览器下面的页面并订阅导航事件:
https://m.facebook.com/dia​​log/ap$p$pquests? +消息= your_message&安培; APP_ID =+your_facebook_appid+&放大器; REDIRECT_URI = HTTPS://m.facebook.com&为=+ user_facebook_ids_CSV +&放大器; SDK = 2及显示器=触摸

Navigate the web browser to the following page and subscribe to the navigating event: "https://m.facebook.com/dialog/apprequests?" + "message=your_message&app_id=" + "your_facebook_appid" + "&redirect_uri=https://m.facebook.com&to=" + user_facebook_ids_CSV + "&sdk=2&display=touch"

FbBrowser.Visibility = Visibility.Visible;
FbBrowser.Navigating + = FbBrowser_Navigating;
FbBrowser.Navigate(URL1);


  1. 您可以处理在航行活动网页的成功和失败响应。

私人无效FbBrowser_Navigating(对象发件人,NavigatingEventArgs E)
        {
            如果(e.Uri.ToString()StartsWith(https://m.facebook.com/?error_$c$c)|| e.Uri.ToString()StartsWith(HTTPS://米facebook.com/?request))
            {
                FbBrowser.Visibility = Visibility.Collapsed;
                FbBrowser.Navigate(新的URI(关于:空白));结果
            }
        }

这篇关于是Facebook的用户,以用户请求可能与W8 / WP8 C#SDK?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆