Facebook C# SDK - 在 Api 调用中使用数组,就像在 PHP 中一样
我正在尝试在 C# 中使用 php 的此代码块:
$fb->api(array(
'method' => 'events.invite',
'eid' => $event_id,
'uids' => $id_array,
'personal_message' => $message,
));
我已经尝试过:
string[,] array = new string[3, 2];
array[0, 0]= "method";
array[0, 1] = "events.invite";
array[1, 0] = "eid";
array[1, 1] = IdEvent.ToString();
array[2, 0] = "uids";
array[2, 1] = "100000339376504";
users = app.Api(array.ToString());
但没有成功,我收到此错误:
error = {"type":"OAuthException","message":" (#803) 您请求的某些别名不存在:system.string[,]"}
有人可以帮我构建这个数组吗?在这个项目中,我使用了 Facebook C# SDK 的版本 4。
谢谢
I'm trying to use this code block of php in C#:
$fb->api(array(
'method' => 'events.invite',
'eid' => $event_id,
'uids' => $id_array,
'personal_message' => $message,
));
I've tried this:
string[,] array = new string[3, 2];
array[0, 0]= "method";
array[0, 1] = "events.invite";
array[1, 0] = "eid";
array[1, 1] = IdEvent.ToString();
array[2, 0] = "uids";
array[2, 1] = "100000339376504";
users = app.Api(array.ToString());
But without success, i'm receiving this error:
error = {"type":"OAuthException","message":"(#803) Some of the aliases you requested do not exist: system.string[,]"}
Can someone help me constructing this array? In this project i've the version 4 of Facebook C# SDK.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
C# SDK 不支持将参数作为数组传递。为了澄清您在做什么,PHP 代码和 C# 数组代码在功能上并不相同。 PHP 代码的正确“替代”是字典。
因此,要修复您的代码,您需要这样做:
另外,请务必注意,我没有使用 Api(字符串路径)覆盖。您应该调用的方法是 Api(IDictionaryparameters)。这是两个截然不同的论点。字符串覆盖的正确使用类似于:
var result = app.Api("me/friends");
最后,我建议您查看 Graph API 而不是 Rest API 。 Rest API 已被弃用。
The C# SDK does not support passing arguments as arrays. To clarify what you are doing, the PHP code and your C# array code are not functionally the same. The correct 'substitution' to the PHP code is a dictionary.
So to fix your code you will want to do this instead:
Also, it is important to note that I am not using the Api(string path) override. The method that you should be calling is Api(IDictionary< string, object > parameters). They are two very different arguments. The correct use of the string override is something like:
var result = app.Api("me/friends");
Lastly, I would suggest you take a look at the Graph API and not the Rest API. The Rest API is being deprecated.