[英]C# Facebook SDK Get Image Picture Unknown facebook response
我在我的MVC應用程序中使用從Nuget下載的C#Facebook SDK https://github.com/facebook-csharp-sdk/facebook-csharp-sdk從頁面獲取公共相冊。
當我試圖獲得專輯封面時,所有請求都可以正常工作,但只有一個。
var PictureUrl = "1713516952246958/picture";
var PictureResult = FB.Get(PictureUrl);
它將引發異常“未知的Facebook響應”。
同樣的要求在這里
任何想法應該是什么問題?
我遇到了完全相同的問題,這讓我發瘋了。
最終我想檢查一下文檔: https : //developers.facebook.com/docs/graph-api/reference/user/picture/
基本上說: By default this edge will return a 302 redirect to the picture image. To get access to the data about the picture, please include **redirect=false** in your query.
By default this edge will return a 302 redirect to the picture image. To get access to the data about the picture, please include **redirect=false** in your query.
因此,您收到的“未知的Facebook響應”錯誤是因為,實際上不是返回有效的JSON,而是返回了302重定向。 當然不能正確解析哪個
因此,嘗試將代碼更改為:
var PictureUrl = "1713516952246958/picture?redirect=false";
var PictureResult = FB.Get(PictureUrl);
而且你應該很甜蜜!
我用這樣的WebClient創建了一個請求:
WebClient p = new WebClient();
p.QueryString.Add("access_token", accessToken);
string responseData = p.DownloadString("https://graph.facebook.com/v2.7/me/picture");
然后返回一個笨拙的數據字符串,其中包含幾個\\ 0001和單詞“ Photoshop 3.0”。
看來C#FaceBook SDK不知道如何處理對API路由的響應。 響應似乎是Photoshop中某種格式的二進制數據。 每當我嘗試該請求並使用郵遞員或瀏覽器對其進行檢查時,它只會將圖像顯示為請求正文,而不會像我期望的那樣顯示任何形式的base64編碼。 這是一個奇怪數據的小屏幕截圖。
這可能是未實現的功能,需要在SDK中完成。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.