▼ バッチビルドキット ▼ クライアントライブラリのダウンロード google-gdata - .NET library for the Google Data API google-gdata : Google の C# サンプル : PhotoBrowserGoogle_Data_API_Setup_1.9.0.0.msiをダウンロードしてインストールすると、 Google_Data_API_Setup_2.2.0.0.msi で再検証しました C:\Program Files\Google\Google Data API SDK\Redist\Google.GData.Client.dll C:\Program Files\Google\Google Data API SDK\Redist\Google.GData.Photos.dll C:\Program Files\Google\Google Data API SDK\Redist\Google.GData.Extensions.dll となるはずなので、カレントディレクトリにコピーして、 vbc.exe /r:Google.GData.Client.dll,Google.GData.Photos.dll,Google.GData.Extensions.dll ソースコード.vb でビルドして実行します
Imports Google.GData.Client Imports Google.GData.Photos Module Module1 Sub Main() ' -------------------------------------------------- ' 引数の処理( ユーザ パスワード アルバム名 ) ' -------------------------------------------------- ' SQL作成に必要なテーブル名を引数から取得する ' 空白を指定したい場合は、"文字列 文字列" のように指定する Dim arguments As String() = Environment.GetCommandLineArgs() ' 引数は3つのみ許可 if arguments.Length <> 4 then Console.WriteLine("引数を指定して下さい") Return end if ' -------------------------------------------------- ' 認証処理 ' -------------------------------------------------- ' Picasa サービスにアプリケーション名を設定 ' companyName-applicationName-versionID で適当に設定 Dim picasaService As PicasaService = New PicasaService("mymymy-photos-v1") ' 認証情報を設定 picasaService.setUserCredentials(arguments(1), arguments(2)) ' トークン文字列 Dim authToken As String = Nothing ' トークンの取得 Try authToken = picasaService.QueryClientLoginToken() Catch ex As Exception Console.WriteLine( ex.Message ) Exit Sub End Try ' トークンの表示( ここでは使用しません ) Console.WriteLine( "▼ トークン" ) Console.WriteLine( authToken ) ' -------------------------------------------------- ' アルバムの処理 ' -------------------------------------------------- ' アルパム一覧を取得する為の要求オブジェクトを作成 Dim query As AlbumQuery = New AlbumQuery() ' ユーザ名より、呼び出し先を設定 query.Uri = New Uri(PicasaQuery.CreatePicasaUri(arguments(1))) ' 一覧の取得 Dim picasaFeed As PicasaFeed = picasaService.Query(query) Dim targetEntry As PicasaEntry = Nothing Console.WriteLine( "▼ 一覧の表示" ) ' 一覧の表示 if (Not picasaFeed is Nothing) and (picasaFeed.Entries.Count > 0) then For Each entry As PicasaEntry In picasaFeed.Entries Console.Write(entry.Title.Text + " : ") Console.WriteLine(entry.GetPhotoExtensionValue(GPhotoNameTable.NumPhotos)) ' 目的のアルバムオブジェクトを保存 if arguments(3) = entry.Title.Text then targetEntry = entry end if Next end if Console.WriteLine( "▼ アルバムの内容" ) ' 保存されたアルバムの内容を再確認 if Not targetEntry is Nothing then Console.WriteLine("アルバムタイトル : " + targetEntry.Title.Text) ' -------------------------------------------------- ' 写真の処理 ' -------------------------------------------------- Dim photoQuery As PhotoQuery = New PhotoQuery(targetEntry.FeedUri) ' 写真一覧の取得 Dim photoFeed As PicasaFeed = picasaService.Query(photoQuery) ' 写真一覧の表示 If (Not photoFeed Is Nothing) And (photoFeed.Entries.Count > 0) Then For Each entryPhoto As PicasaEntry In photoFeed.Entries ' 通常はアップロードしたファイル名 Console.WriteLine(entryPhoto.Title.Text) ' Picasa の HTML ページ Console.WriteLine(entryPhoto.AlternateUri.Content ) ' 画像の URL Console.WriteLine(entryPhoto.Media.Content.Url) Console.WriteLine() Next End If end if End Sub End Module
Protocol Reference 実行サンプルvb.net>image_urllist.exe user password 画像 ▼ トークン DQAAABABAACUVSy0cLeHFszdiXR52VqipNzkwhG--jNYFdZsJiE-2tNWslwWDZ01PDFdGVSGEmo-54Es rnC4plJ5dqWnb8ttvGwHR6_Hv7FfNcTV2Yvl0hK0DjVcCDKv4AGtcL5SXKz58NUAYFQpUU_xYuKSiH3Y nipVGeJsnpKgLbJGJvBc0I7qYJFlqIy4ydAnpxjtd5jJEe6lVJPb08Dgszkzi4C_DAT-5Y1tLRWkX4iG 9LrwV72TAO7bYtGkE59E0GL6V96DmkQyhGD8e6QW6PYbtGq2zV3T49PqWXYCMyHuyu4oQ7zEVrCka51M eVc--4wdsNEzn5-ORFfAQ5dDOkv1H2TWJZoUNtdjfx7QhqDIsSPeSg ▼ 一覧の表示 自動バックアップ : 2 Google DATA : 1 画像 : 5 2013/08/31 : 2 2013-08-15 : 1 2013-08-09 : 1 2013/08/09 : 1 書籍 : 1 2013-08-05 : 2 スクラップブック写真 : 1 プロフィール写真 : 1 2013-08-15 : 1 ▼ アルバムの内容 アルバムタイトル : 画像 Koala.jpg https://picasaweb.google.com/1062795259696282242/aBylLD02#6106631643771454306 https://lh.googleusercontent.com/-NAgA591vjCo/VL8dIC0oQ2I/AAAAAAAAAj8/auHvt-kPf 9M/Koala.jpg Chrysanthemum.jpg https://picasaweb.google.com/1062795259696282242/aBylLD02#6106632684030319666 https://lh.googleusercontent.com/-B_9ML605-us/VL8eEmFq3DI/AAAAAAAAAkk/XEdyJhv_R is/Chrysanthemum.jpg Desert.jpg https://picasaweb.google.com/1062795259696282242/aBylLD02#6106632684185326466 https://lh.googleusercontent.com/-35nqu23mW98/VL8eEmqoE4I/AAAAAAAAAkY/g90EGpZOT DM/Desert.jpg Hydrangeas.jpg https://picasaweb.google.com/1062795249696282242/aBylLD02#6106632687178019842 https://lh.googleusercontent.com/-S6Ip9iBwt00/VL8eEx0I9AI/AAAAAAAAAkc/VYd-YUeEC w4/Hydrangeas.jpg Jellyfish.jpg https://picasaweb.google.com/1062795259696282242/aBylLD02#6106632704441986402 https://lh.googleusercontent.com/-og4Rsof929w/VL8eFyIMLWI/AAAAAAAAAkg/1kZH2SSCR 9U/Jellyfish.jpg▼ C# ( Code Translation for .NET (C#<->VB.NET) でVBを変換 )
using System; using Google.GData.Client; using Google.GData.Photos; class Module1 { static void Main() { string[] arguments = Environment.GetCommandLineArgs(); if ((arguments.Length != 4)) { return; } PicasaService picasaService = new PicasaService("mymymy-photos-v1"); picasaService.setUserCredentials(arguments[1], arguments[2]); string authToken = null; try { authToken = picasaService.QueryClientLoginToken(); } catch (Exception ex) { Console.WriteLine(ex.Message); return; } Console.WriteLine("▼ token"); Console.WriteLine(authToken); AlbumQuery query = new AlbumQuery(); query.Uri = new Uri(PicasaQuery.CreatePicasaUri(arguments[1])); PicasaFeed picasaFeed = picasaService.Query(query); PicasaEntry targetEntry = null; Console.WriteLine("▼ list"); if ((!(picasaFeed == null) && (picasaFeed.Entries.Count > 0))) { foreach (PicasaEntry entry in picasaFeed.Entries) { Console.Write((entry.Title.Text + " : ")); Console.WriteLine(entry.GetPhotoExtensionValue(GPhotoNameTable.NumPhotos)); if ((arguments[3] == entry.Title.Text)) { targetEntry = entry; } } } Console.WriteLine("▼ albam"); if (!(targetEntry == null)) { Console.WriteLine(("title : " + targetEntry.Title.Text)); PhotoQuery photoQuery = new PhotoQuery(targetEntry.FeedUri); PicasaFeed photoFeed = picasaService.Query(photoQuery); if ((!(photoFeed == null) && (photoFeed.Entries.Count > 0))) { foreach (PicasaEntry entryPhoto in photoFeed.Entries) { Console.WriteLine(entryPhoto.Title.Text); Console.WriteLine(entryPhoto.AlternateUri.Content); Console.WriteLine(entryPhoto.Media.Content.Url); Console.WriteLine(); } } } } }
|
【VB.NET : テクニカルの最新記事】
- VB.net(VS2010) で COM へ公開して、WSH(VBScript) で利用する( C# でも同様 )
- VB.net : Picasa にアクセスする為に、Google Data API にログインしてトークンを取得する
- VB.net : Win32API 呼び出し : GetWindowsDirectory
- VB.net : 画像の上にテキストを半透明で出力する
- VB.net と C# における KeyPress イベントの受け取り方
- VB.net : フォーカス イベントの発生順序と注意事項
- VB.net クリップボードの処理 ( C# は注意 )
- VB.net : 自分自身(というか元々プロテクトメソッド)を呼び出す遅延処理用プライベートタイマークラス