0
因此,我有一個Facebook上的應用程序,它擁有publish_stream,manage_pages的權限,以及我迄今能夠將'文本'更新發布到我自己的個人資料中,顯示'通過應用程序名稱'。如何使用應用程序代表我的頁面將鏈接,圖片等發佈到我的Facebook頁面?
然後我試着從這個應用程序發佈到我的頁面上代表頁面。
我能做到這一點的client.Post("/page name/feed", new { message = "abcd" });
(純文本),但如果我嘗試發佈鏈接,標題或圖片仍然張貼我的網頁上的,但我的個人資料像我分享該網頁上的東西,不會作爲我的頁面發佈。
我正在使用此方法發佈。
private void CheckAuthorization()
{
string app_id = "APP_ID";
string app_secret = "APP_SECRET";
string scope = "publish_stream,manage_pages,";
if (Request["code"] == null)
{
Response.Redirect(string.Format(
"https://graph.facebook.com/oauth/authorize?client_id={0}&redirect_uri={1}&scope={2}",
app_id, Request.Url.AbsoluteUri, scope));
}
else
{
Dictionary<string, string> tokens = new Dictionary<string, string>();
string url = string.Format("https://graph.facebook.com/oauth/access_token?client_id={0}&redirect_uri={1}&scope={2}&code={3}&client_secret={4}",
app_id, Request.Url.AbsoluteUri, scope, Request["code"].ToString(), app_secret);
HttpWebRequest request = System.Net.WebRequest.Create(url) as HttpWebRequest;
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
StreamReader reader = new StreamReader(response.GetResponseStream());
string vals = reader.ReadToEnd();
foreach (string token in vals.Split('&'))
{
//meh.aspx?token1=steve&token2=jake&...
tokens.Add(token.Substring(0, token.IndexOf("=")),
token.Substring(token.IndexOf("=") + 1, token.Length - token.IndexOf("=") - 1));
}
}
string access_tokens = tokens["access_token"];
var client = new FacebookClient(access_tokens);
dynamic parameters = new ExpandoObject();
parameters.message = "Check out this New Item";
parameters.link = "https://www.example.com";
parameters.picture = "http://www.example.com/images/img.jpg";
parameters.name = "Item Title";
parameters.caption = "Caption for the link";
client.Post("/AllTheMed/feed", new { message = "lsjlsjlsjkldf" });
}
}
請不要發佈您的應用程序的祕密,它應該是保守祕密。所以請重新生成它。另外,請嘗試使用頁面訪問令牌發佈並檢查您是否解決了您的問題。 –
@Anvesh Saxena對不起,我很着急,是的,我已經嘗試使用頁面訪問令牌擴展令牌,但沒有好 –