获得一个特定的配置文件ID使用的GData .NET分析API 2.4注册帐户 [英] Getting an specific ProfileId from registered Accounts using GData .NET Analytics API 2.4

查看:122
本文介绍了获得一个特定的配置文件ID使用的GData .NET分析API 2.4注册帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去的文章中,我想通了,如何检索度量数据有一定配置文件ID:
<一href=\"http://stackoverflow.com/questions/12113204/exception-thrown-when-using-gdata-net-analytics-api\">Exception使用.NET的GData分析API 时抛出

In a past entry I figured out how to retrieve the metrics data for a certain profile id: Exception thrown when using GData .NET Analytics API

现在我想找回我的账户谷歌Analytics(分析)列表中匹配一个注册的域名有一定的个人资料的ID,这是很容易过,但最后谷歌之后升级到管理/核心报表API 3.0,旧的2.3饲料已关闭并如期AccountsFeed相关code是行不通的。

Now I would like to retrieve a certain profile id that matches a registered domain name on my accounts list in Google Analytics, this was easy before, but after the last Google upgrade to Management/Core Reporting API 3.0, the old 2.3 feed has been shutdown and the AccountsFeed related code is not working as expected.

推荐答案

使用这里发表建议:<一href=\"http://$c$c.google.com/p/gdata-issues/issues/detail?can=2&start=0&num=100&q=&colspec=API%20ID%20Type%20Status%20Priority%20Stars%20Summary&groupby=&sort=&id=2955\" rel=\"nofollow\">http://$c$c.google.com/p/gdata-issues/issues/detail?can=2&start=0&num=100&q=&colspec=API%20ID%20Type%20Status%20Priority%20Stars%20Summary&groupby=&sort=&id=2955 ,我想出了这个code工作来完成我需要:

Using a suggestion posted here: http://code.google.com/p/gdata-issues/issues/detail?can=2&start=0&num=100&q=&colspec=API%20ID%20Type%20Status%20Priority%20Stars%20Summary&groupby=&sort=&id=2955 , I came up with this code works to accomplish what I need:

Imports Google
Imports Google.Analytics
Imports Google.GData.Analytics
Imports System.Collections.Generic
Imports System.Collections

Public Function GetProfileId(ByVal DomainText As String) As String

Dim Ids As String = String.Empty
Dim service As GData.Analytics.AnalyticsService = New GData.Analytics.AnalyticsService("MyAnalyticsService")
service.setUserCredentials(username, pass)

//Dim factory As GData.Client.GDataGAuthRequestFactory = CType(service.RequestFactory, GData.Client.GDataGAuthRequestFactory)
//factory.AccountType = "GOOGLE" 
//factory.UseSSL = True
//service.RequestFactory = factory    

Dim aF As DataFeed = service.Query(New DataQuery("https://www.googleapis.com/analytics/v2.4/management/accounts"))
Dim webPropsUrl As String = "" 
For Each o As GData.Client.AtomEntry In aF.Entries
     //webproperties
      If o.Title.Text.Contains(DomainText) Then
           webPropsUrl = o.Links.Item(1).HRef.Content
           Exit For
      End If
Next

Dim wpF As DataFeed = service.Query(New DataQuery(webPropsUrl))
Dim profileFeedUrl As String = "" 
For Each entry As DataEntry In wpF.Entries
    //profiles
     profileFeedUrl = entry.Links.Item(2).HRef.Content
     Exit For
Next

Dim prF As DataFeed = service.Query(New DataQuery(profileFeedUrl))
Dim profileUrl As String = "" 
For Each profd As DataEntry In prF.Entries
     profileUrl = profd.Links.Item(0).HRef.Content
     Exit For
Next

Dim profileId As String = ""
profileId = profileUrl.Split("/")(profileUrl.Split("/").Length - 1)

Return profileId

End Function

这篇关于获得一个特定的配置文件ID使用的GData .NET分析API 2.4注册帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆