Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# (OAutheException-#200)(#200)未发布的帖子必须作为页面本身发布到页面_C#_Asp.net_Facebook_Facebook Graph Api - Fatal编程技术网

C# (OAutheException-#200)(#200)未发布的帖子必须作为页面本身发布到页面

C# (OAutheException-#200)(#200)未发布的帖子必须作为页面本身发布到页面,c#,asp.net,facebook,facebook-graph-api,C#,Asp.net,Facebook,Facebook Graph Api,我已经写了下面的功能,张贴一张照片到FB页面。但是,如果错误是“(OAutheException-#200)(#200)未发布的帖子必须作为页面本身发布到页面。” private void posttofPage() { 字符串app_id=ConfigurationManager.AppSettings[“FBAppKey”]; 字符串app_secret=ConfigurationManager.AppSettings[“FBSecretKey”]; 字符串范围=ConfigurationM

我已经写了下面的功能,张贴一张照片到FB页面。但是,如果错误是“(OAutheException-#200)(#200)未发布的帖子必须作为页面本身发布到页面。”

private void posttofPage()
{
字符串app_id=ConfigurationManager.AppSettings[“FBAppKey”];
字符串app_secret=ConfigurationManager.AppSettings[“FBSecretKey”];
字符串范围=ConfigurationManager.AppSettings[“FBPermission”];
字符串访问令牌;
if(会话[“访问令牌”]==null)
access_token=getAccessToken();
其他的
access_token=会话[“access_token”]。ToString();
var client=新的FacebookClient(访问令牌);
List imgs=(List)会话[“local_processedImgs”];
DateTime dt=新日期时间(转换为32(ddlYear.SelectedValue)
,转换为.ToInt32(ddlmount.SelectedValue)
,转换为.ToInt32(ddlDate.SelectedValue)
,转换为.ToInt32(ddlHour.SelectedValue)
,Convert.ToInt32(ddlMin.SelectedValue)
,0);
双UTC=Facebook.DateTimeConvertor.ToUnixTime(dt);
动态post=null;
动态参数=新的ExpandooObject();
parameters.source=新的FacebookMediaObject
{
ContentType=“image/”+Path.GetExtension(imgs[0]),
FileName=imgs[0]
}.SetValue(File.ReadAllBytes(imgs[0]);
parameters.message=CKEditor1.Text;
parameters.scheduled_publish_time=UTC;
parameters.published=false;
parameters.scope=范围;
尝试
{
post=client.post(“/”+ddlFBPage.SelectedValue+“/photos”,参数);
}
捕获(例外情况除外)
{
//错误
}
}
请帮我做这个

--

问候


迪帕克雷

我自己买的。有多种类型的令牌。在我上面的代码中,我传递的是“用户访问令牌”,而不是“页面访问令牌”。要生成“页面访问令牌”,请使用以下URL的get方法:

string url = string.Format(
    "https://graph.facebook.com/{0}?fields=access_token&access_token={1}",
    pageID, user_access_token);

希望这会有所帮助:)

非常有用。为我们节省了很多时间和挫折。
string url = string.Format(
    "https://graph.facebook.com/{0}?fields=access_token&access_token={1}",
    pageID, user_access_token);