3

I am trying to run a Google pagespeed api request via a VB.Net WindowsForm app and though i can get a response back for the below request i cannot workout how to get it work with a Mobile strategy.

here is my working code for a desktop request:

Dim url As String = "http://news.bbc.co.uk"

Dim service = New PagespeedonlineService(New BaseClientService.Initializer() With { _
    .ApiKey = "My Api Code", _
    .ApplicationName = "PageSpeedOnline API Sample" _
})

Dim res = service.Pagespeedapi.Runpagespeed(url).Execute()

Here is a link to googles pagespeed page: https://developers.google.com/speed/docs/insights/v1/getting_started

Note I am visual studio 2012 with Nuget package for the api.

JSuar
  • 21,056
  • 4
  • 39
  • 83
Mannie Singh
  • 119
  • 3
  • 17
  • you can find the answer in this thread. Hope it helps - http://stackoverflow.com/questions/34291450/google-pagespeed-api-dotnet-net/34292461 – Guru Prasad Jun 29 '16 at 10:02

1 Answers1

1

You need to create a RunpagespeedRequest object with the settings you want. Runpagespeed() is a virtual method that should be used by the RunpagespeedRequest once you create it.

Untested Code

Dim url As String = "http://news.bbc.co.uk"

Dim service = New PagespeedonlineService(New BaseClientService.Initializer() With { _
    .ApiKey = "My Api Code", _
    .ApplicationName = "PageSpeedOnline API Sample" _
 })

Dim res = New RunpagespeedRequest(service, url);
res.Strategy = PagespeedapiResource.RunpagespeedRequest.StrategyEnum.Mobile
res.Runpagespeed(url).Execute()

The above code probably won't work, but I think it will get you in the direction in order to set any other properties.

PagespeedapiResource Class Reference PagespeedapiResource.RunpagespeedRequest Class Reference

JSuar
  • 21,056
  • 4
  • 39
  • 83