2014-01-21 256 views
0

謝謝,我非常感謝您的幫助!Google API DotNet Youtube播放列表失敗,無播放列表ID

我想讓.NET的Google API客戶端正常工作,但我不知道如何做甚至簡單的事情。我的目標是建立一個網頁,在頂部加載一個YouTube播放列表播放器,並只列出其下方其他曲目的相關信息。

你能幫我解決一下讓客戶端運行的第一個問題嗎?

我有一個.NET 4.0網站實例,我已經通過nuget軟件包管理器安裝了DotNet Google API。我認爲問題在於我無法弄清楚如何將PlaylistID傳遞給客戶端請求。在下面的代碼中,我可以指定PlaylistID?

Imports Google.Apis.YouTube.v3 
Imports Google.Apis.YouTube.v3.Data 

Dim Initialiser As New Google.Apis.Services.BaseClientService.Initializer() 
Initialiser.ApiKey = "My Server API Key" 
Dim Service As YouTubeService = New YouTubeService(Initialiser) 
Dim Result As PlaylistItemListResponse 
Result = Service.PlaylistItems().List("snippet").Execute() 
If Not Result.Items Is Nothing Then 
    Dim XPathDocument As System.Xml.XPath.XPathDocument = GenerateXPathDocument(Result.Items) 
    SamplerXml.XPathNavigator = XPathDocument.CreateNavigator 
End If 

錯誤輸出是:

2014-01-21 12:14:30.1894 Error ASP.global_asax 
Application_Error: GET /sampler/120 
BaseExceptionType: Google.GoogleApiException 
    Type=System.Web.HttpUnhandledException 
    Message=Exception of type 'System.Web.HttpUnhandledException' was thrown. 
    Stack= 
at System.Web.UI.Page.HandleError(Exception e) 
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 
at System.Web.UI.Page.ProcessRequest() 
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) 
at System.Web.UI.Page.ProcessRequest(HttpContext context) 
at ASP.templates_sampler_default_aspx.ProcessRequest(HttpContext context) 
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 

Type=Google.GoogleApiException 
Message=Google.Apis.Requests.RequestError 
No filter selected. [400] 
Errors [ 
    Message[No filter selected.] Location[ - parameter] Reason[missingRequiredParameter] Domain[youtube.parameter] 
] 

Stack= 
at Google.Apis.Requests.ClientServiceRequest`1.Execute() in c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\output\default\Src\GoogleApis\Apis\Requests\ClientServiceRequest.cs:line 93 
at SiteCode.Templates.Sampler.Page_Load(Object sender, EventArgs e) in C:\svn-work\playlistproject\site\templates\sampler\Default.aspx.vb:line 54 
at System.EventHandler.Invoke(Object sender, EventArgs e) 
at System.Web.UI.Control.OnLoad(EventArgs e) 
at System.Web.UI.Control.LoadRecursive() 
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 

謝謝您的幫助和您的時間!

回答

0

答案結果很簡單。所以我不得不創建列表請求,然後設置播放列表ID,然後執行請求。有時我可以真的很慢...

我希望這可以幫助別人!