gpt4 book ai didi

google-analytics-api - {"Unexpected character encountered while parsing value: <. Path ' ', line 0, position 0."} in google analytics api

转载 作者:行者123 更新时间:2023-12-04 19:28:36 27 4
gpt4 key购买 nike

我正在使用示例 code来自 GitHub。

            #region code

AnalyticsService service;

// Service account Authentication
String SERVICE_ACCOUNT_EMAIL =" ";// removed the account email
string SERVICE_ACCOUNT_KEYFILE = @"C:\Projects\Test\TMBWebsite-7f016e7c3562.p12";
service = DaimtoAnalyticsAuthenticationHelper.AuthenticateServiceAccount(SERVICE_ACCOUNT_EMAIL,SERVICE_ACCOUNT_KEYFILE);




//////Get account summary and display them.
foreach (AccountSummary account in DaimtoAnaltyicsManagmentHelper.AccountSummaryList(service).Items)
{
// Account
Console.WriteLine("Account: " + account.Name + "(" + account.Id + ")");

foreach (WebPropertySummary wp in account.WebProperties)
{

// Web Properties within that account
Console.WriteLine("\tWeb Property: " + wp.Name + "(" + wp.Id + ")");


//Don't forget to check its not null. Believe it or not it could be.
if (wp.Profiles != null)
{

foreach (ProfileSummary profile in wp.Profiles)
{
// Profiles with in that web property.
Console.WriteLine("\t\tProfile: " + profile.Name + "(" + profile.Id + ")");
}
}
}
}

#endregion

//认证服务

        if (!File.Exists(keyFilePath))
{
Console.WriteLine("An Error occurred - Key file does not exist");
return null;
}

string[] scopes = new string[] { AnalyticsService.Scope.Analytics, // view and manage your analytics data
AnalyticsService.Scope.AnalyticsEdit, // edit management actives
AnalyticsService.Scope.AnalyticsManageUsers, // manage users
AnalyticsService.Scope.AnalyticsReadonly}; // View analytics data

X509Certificate2 certificate = new X509Certificate2(keyFilePath, "notasecret", X509KeyStorageFlags.Exportable);
// X509Certificate2 certificate = new X509Certificate2(keyFilePath, "notasecret", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
try
{
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = scopes
}.FromCertificate(certificate));

// Create the service.
AnalyticsService service = new AnalyticsService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Analytics API Sample",
});
return service;
}
catch (Exception ex)
{

Console.WriteLine(ex.InnerException);
return null;

}

#region 帐户摘要

    /// <summary>
/// Lists account summaries (lightweight tree comprised of accounts/properties/profiles) to which the user has access.
/// Documentation: https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/accountSummaries/list
/// </summary>
/// <param name="service">Valid authenticated Analytics Service</param>
/// <returns>List of Account Summaries resource - https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/accountSummaries</returns>
public static AccountSummaries AccountSummaryList(AnalyticsService service)
{

//List all of the activities in the specified collection for the current user.
// Documentation: https://developers.google.com/+/api/latest/activities/list

//ManagementResource.AccountSummariesResource.ListRequest list = service.Management.AccountSummaries.List();
ManagementResource.AccountSummariesResource.ListRequest list = service.Management.AccountSummaries.List();
list.Alt = ManagementResource.AccountSummariesResource.ListRequest.AltEnum.Json;
list.MaxResults = 1000; // Maximum number of Account Summaries to return per request.

AccountSummaries feed = list.Execute();
List<AccountSummary> allRows = new List<AccountSummary>();

//var getRequest = settingsService.Groups.Get("samplegroup@example.com");
//getRequest.Alt = "json";
//var settings = getRequest.Execute();

//// Loop through until we arrive at an empty page
while (feed.Items != null)
{

allRows.AddRange(feed.Items);

// We will know we are on the last page when the next page token is
// null.
// If this is the case, break.
if (feed.NextLink == null)
{
break;
}

// Prepare the next page of results
list.StartIndex = feed.StartIndex + list.MaxResults;
// Execute and process the next page request
feed = list.Execute();

}

feed.Items = allRows;

return feed;

}
#endregion

AccountSummaries feed = list.Execute();抛出异常:{“解析值时遇到意外字符:<。路径'',第0行,位置0。”}在谷歌分析api中

最佳答案

我想通了。防火墙阻止了我的请求。在我的配置文件中添加了下面给定的代码并且工作了 <system.net> <defaultProxy useDefaultCredentials="true"> <proxy proxyaddress="My proxy address here" usesystemdefault="True"/> </defaultProxy> </system.net>

关于google-analytics-api - {"Unexpected character encountered while parsing value: <. Path ' ', line 0, position 0."} in google analytics api,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30565438/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com