測試下載圖片 GraphApiAsyncExample();
1. Ref: http://www.digitalcoding.com/Code-Snippets/C-Sharp/C-Code-Snippet-Download-Image-from-URL.html
1.1 下載網頁圖片
2 用Ref1建立 Class DownloadImageClass, 製作DownloadImage類別方法。
3. 修改 GraphApiAsyncExample()
var fb = new FacebookClient(_accessToken);
try
{
dynamic result = fb.Get("/me");
var name = result.name;
lnkName.Text = "Hi " + name;
lnkName.LinkClicked += (o, e) => Process.Start(result.link);
// available picture types: square (50x50), small (50xvariable height), large (about 200x variable height) (all size in pixels)
// for more info visit http://developers.facebook.com/docs/reference/api
picProfilePic.LoadAsync(string.Format("https://graph.facebook.com/{0}/picture?type={1}", result.id, "square"));
// ----------- 建置image 物件
// ----------- 下載網址圖片
// ----------- 另存圖檔 Test1.jpg
Image im = null;
im = DownloadImageClass.DownloadImage(string.Format("https://graph.facebook.com/{0}/picture?type={1}", result.id, "square"));
im.Save("Test1.jpg");
4. 測試OK!
沒有留言:
張貼留言