Quick and dirty REST query

57 views
Skip to first unread message

l...@winzee.com

unread,
Feb 17, 2012, 2:16:04 PM2/17/12
to excel-r...@googlegroups.com
Hi,

I've been trying to implement a quick and dirty query to this api:  http://support.flurry.com/index.php?title=EventMetrics#EventMetrics_API

So I tried to work starting from the following adhoc code on your site and hard code the URL but it does not work. I get a "subscript out of range"

Public Sub testLMG()
    Dim cr As cRest
    Set cr = restQuery("SheetName", , "", , _
        "responseData.results", False)
    
End Sub

I put column names on top of the SheetName sheet.

So, what would be the most quick and dirty way to get all data returned from an API call like that?

Thanks!

Bruce McPherson

unread,
Feb 17, 2012, 2:21:43 PM2/17/12
to excel-r...@googlegroups.com
Hi
Can you let me see the data returned when you enter the URL into a browser. I can't do it myself without your key and access code
Bruce

Sent from my iPad
--
You received this message because you are subscribed to the Google Groups "Excel Ramblings" group.
To view this discussion on the web visit https://groups.google.com/d/msg/excel-ramblings/-/KYgW0bgsHysJ.
To post to this group, send email to excel-r...@googlegroups.com.
To unsubscribe from this group, send email to excel-ramblin...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/excel-ramblings?hl=en.

Louis-Marius Gendreau

unread,
Feb 17, 2012, 2:47:22 PM2/17/12
to excel-r...@googlegroups.com
Hi Bruce, 

Thanks for the help.  I obfuscated the keys...

{"@type":"Summary","@startDate":"2012-01-01","@endDate":"2012-12-31","@version":"1.0","@generatedDate":"2/17/12 11:45 AM","event":[{"@usersLastWeek":"0","@usersLastMonth":"0","@usersLastDay":"0","@totalSessions":"21","@totalCount":"29","@eventName":"storeHard","@avgUsersLastWeek":"0","@avgUsersLastMonth":"0","@avgUsersLastDay":"0"},{"@usersLastWeek":"0","@usersLastMonth":"0","@usersLastDay":"0","@totalSessions":"217","@totalCount":"234","@eventName":"session","@avgUsersLastWeek":"0","@avgUsersLastMonth":"0","@avgUsersLastDay":"0"},{"@usersLastWeek":"0","@usersLastMonth":"0","@usersLastDay":"0","@totalSessions":"116","@totalCount":"184","@eventName":"storeSoft","@avgUsersLastWeek":"0","@avgUsersLastMonth":"0","@avgUsersLastDay":"0"},{"@usersLastWeek":"0","@usersLastMonth":"0","@usersLastDay":"0","@totalSessions":"16","@totalCount":"34","@eventName":"purchase","@avgUsersLastWeek":"0","@avgUsersLastMonth":"0","@avgUsersLastDay":"0"},{"@usersLastWeek":"0","@usersLastMonth":"0","@usersLastDay":"0","@totalSessions":"130","@totalCount":"175","@eventName":"game","@avgUsersLastWeek":"0","@avgUsersLastMonth":"0","@avgUsersLastDay":"0"},{"@usersLastWeek":"0","@usersLastMonth":"0","@usersLastDay":"0","@totalSessions":"1","@totalCount":"2","@eventName":"revenue","@avgUsersLastWeek":"0","@avgUsersLastMonth":"0","@avgUsersLastDay":"0"}]}
--
Louis-Marius Gendreau
T: 514-285-4665
F: 514-285-1621

Bruce Mcpherson

unread,
Feb 17, 2012, 4:13:58 PM2/17/12
to excel-r...@googlegroups.com
Hi

Since this returns an array for each 'event' element,  you'll need to describe how you would want to organize the output. I.m guessing you would want to create columns for each of the event properties, plus repeat the common properties as columns for each event.. this is straightforward - just let me know if you need my help.

 @type         Summary
@startDate    2012-01-01
@endDate      2012-12-31
@version      1.0
@generatedDate              2/17/12 11:45 AM

Here's how to access the array to allow you to populate whatever you need manually. Note i've just popped in the string you gave me since I cant access the URL directly. You would revert to the URL argument and wouldnt need to specify the string 'y'.

Public Sub testFixdirect()
    Dim cr As New cRest, joe As cJobject, _
        dSet As New cDataSet, x As cRest, _
        jo As cJobject, y As String
    y = _
"{'@type':'Summary','@startDate':'2012-01-01','@endDate':'2012-12-31','@version':'1.0','@generatedDate':'2/17/12 11:45 AM'," _
& "'event':[{'@usersLastWeek':'0','@usersLastMonth':'0','@usersLastDay':'0','@totalSessions':'21','@totalCount':'29'," _
& "'@eventName':'storeHard','@avgUsersLastWeek':'0','@avgUsersLastMonth':'0','@avgUsersLastDay':'0'}," _
& "{'@usersLastWeek':'0','@usersLastMonth':'0','@usersLastDay':'0','@totalSessions':'217','@totalCount':'234'," _
& "'@eventName':'session','@avgUsersLastWeek':'0','@avgUsersLastMonth':'0','@avgUsersLastDay':'0'}," _
& "{'@usersLastWeek':'0','@usersLastMonth':'0','@usersLastDay':'0','@totalSessions':'116','@totalCount':'184'," _
& "'@eventName':'storeSoft','@avgUsersLastWeek':'0','@avgUsersLastMonth':'0','@avgUsersLastDay':'0'}," _
& "{'@usersLastWeek':'0','@usersLastMonth':'0','@usersLastDay':'0','@totalSessions':'16','@totalCount':'34'," _
& "'@eventName':'purchase','@avgUsersLastWeek':'0','@avgUsersLastMonth':'0','@avgUsersLastDay':'0'}," _
& "{'@usersLastWeek':'0','@usersLastMonth':'0','@usersLastDay':'0','@totalSessions':'130','@totalCount':'175'," _
& "'@eventName':'game','@avgUsersLastWeek':'0','@avgUsersLastMonth':'0','@avgUsersLastDay':'0'},{'@usersLastWeek':'0'," _
& "'@usersLastMonth':'0','@usersLastDay':'0','@totalSessions':'1','@totalCount':'2','@eventName':'revenue','@avgUsersLastWeek':'0'," _
& "'@avgUsersLastMonth':'0','@avgUsersLastDay':'0'}]}"

    Set x = cr.init("", erSingleQuery, , , _
            dSet.populateData(wholeSheet("cfix"), , , , , , True), _
            False, _
            "", , True).execute(, y)
    For Each jo In x.jObject.children
        Debug.Print jo.key, jo.value
    Next jo
    For Each jo In x.jObject.child("event").children
        For Each joe In jo.children
            Debug.Print joe.fullKey, joe.toString
        Next joe
    Next jo
    
                

End Sub

.. this gives this result

@type         Summary
@startDate    2012-01-01
@endDate      2012-12-31
@version      1.0
@generatedDate              2/17/12 11:45 AM
event         
_deserialization.event.1.@usersLastWeek   0
_deserialization.event.1.@usersLastMonth  0
_deserialization.event.1.@usersLastDay    0
_deserialization.event.1.@totalSessions   21
_deserialization.event.1.@totalCount      29
_deserialization.event.1.@eventName       storeHard
_deserialization.event.1.@avgUsersLastWeek              0
_deserialization.event.1.@avgUsersLastMonth             0
_deserialization.event.1.@avgUsersLastDay 0
_deserialization.event.2.@usersLastWeek   0
_deserialization.event.2.@usersLastMonth  0
_deserialization.event.2.@usersLastDay    0
_deserialization.event.2.@totalSessions   217
_deserialization.event.2.@totalCount      234
_deserialization.event.2.@eventName       session
_deserialization.event.2.@avgUsersLastWeek              0
_deserialization.event.2.@avgUsersLastMonth             0
_deserialization.event.2.@avgUsersLastDay 0
_deserialization.event.3.@usersLastWeek   0
_deserialization.event.3.@usersLastMonth  0
_deserialization.event.3.@usersLastDay    0
_deserialization.event.3.@totalSessions   116
_deserialization.event.3.@totalCount      184
_deserialization.event.3.@eventName       storeSoft
_deserialization.event.3.@avgUsersLastWeek              0
_deserialization.event.3.@avgUsersLastMonth             0
_deserialization.event.3.@avgUsersLastDay 0
_deserialization.event.4.@usersLastWeek   0
_deserialization.event.4.@usersLastMonth  0
_deserialization.event.4.@usersLastDay    0
_deserialization.event.4.@totalSessions   16
_deserialization.event.4.@totalCount      34
_deserialization.event.4.@eventName       purchase
_deserialization.event.4.@avgUsersLastWeek              0
_deserialization.event.4.@avgUsersLastMonth             0
_deserialization.event.4.@avgUsersLastDay 0
_deserialization.event.5.@usersLastWeek   0
_deserialization.event.5.@usersLastMonth  0
_deserialization.event.5.@usersLastDay    0
_deserialization.event.5.@totalSessions   130
_deserialization.event.5.@totalCount      175
_deserialization.event.5.@eventName       game
_deserialization.event.5.@avgUsersLastWeek              0
_deserialization.event.5.@avgUsersLastMonth             0
_deserialization.event.5.@avgUsersLastDay 0
_deserialization.event.6.@usersLastWeek   0
_deserialization.event.6.@usersLastMonth  0
_deserialization.event.6.@usersLastDay    0
_deserialization.event.6.@totalSessions   1
_deserialization.event.6.@totalCount      2
_deserialization.event.6.@eventName       revenue
_deserialization.event.6.@avgUsersLastWeek              0
_deserialization.event.6.@avgUsersLastMonth             0
_deserialization.event.6.@avgUsersLastDay 0

Louis-Marius Gendreau

unread,
Feb 17, 2012, 4:30:29 PM2/17/12
to excel-r...@googlegroups.com
Wow thanks!

And how would you populate 'y" with the json string?

Bruce McPherson

unread,
Feb 17, 2012, 4:35:20 PM2/17/12
to excel-r...@googlegroups.com
Just remove all the arguments from the execute method, eliminate y, and pass the URL string as an argument to the cr.init method

Sent from my iPad

On 17 Feb 2012, at 21:30, Louis-Marius Gendreau <l...@winzee.com> wrote:

Wow thanks!

And how would you populate 'y" with the json string?

On Fri, Feb 17, 2012 at 4:13 PM, Bruce Mcpherson <br...@mcpher.com> wrote:
Hi

Since this returns an array for each 'event' element,  you'll need to describe how you would want to organize the output. I.m guessing you would want to create columns for each of the event properties, plus repeat the common properties as columns for each event.. this is straightforward - just let me know if you need my help.

 @type         Summarythe cr 
Reply all
Reply to author
Forward
0 new messages