Ticket #890: testsdf.au3

File testsdf.au3, 1.2 KB (added by JRSmile, 15 years ago)

example of execute and objects

Line 
1#include <array.au3>
2Dim $attribs[3][2]
3$attribs[0][0] = "method"
4$attribs[0][1] = "user.getlovedtracks"
5$attribs[1][0] = "api_key"
6$attribs[1][1] = 'aa72a3b1161d33d0eba36f986fa1fb43'
7$attribs[2][0] = "user"
8$attribs[2][1] = "JRSmile"
9$res = __lastfm_send($attribs)
10ConsoleWrite($res & @CRLF)
11
12
13Func __lastfm_send($attribs)
14        Local $namespace
15        If (Not IsArray($attribs)) Or (UBound($attribs, 0) <> 2) Then Return SetError(1, 0, False)
16        $f = ObjCreate("pocketXMLRPC.Factory")
17        $mystruct = ObjCreate("PocketXMLRPC.Struct")
18        For $i = 0 To UBound($attribs) - 1
19                If $attribs[$i][0] = "method" Then
20                        $tmp = StringSplit($attribs[$i][1],".", 1)
21                        $method = $tmp[2]
22                        $namespace = $tmp[1]
23                Else
24                        Execute("$mystruct." & $attribs[$i][0] & ' = ' & "$attribs[$i][1]" & '')
25                        ConsoleWrite("$mystruct." & $attribs[$i][0] & ' = ' & "$attribs[$i][1]" & ' ==> ' & $attribs[$i][1] & @CRLF)
26                EndIf
27        Next
28        $mystruct.user = $attribs[2][1]
29    $mystruct.api_key = $attribs[1][1]
30       
31        $objReq = $f.Proxy("http://ws.audioscrobbler.com/2.0/", $namespace & ".")
32        $r = Execute("$objreq." & $method & "($mystruct)")
33        $mystruct = 0
34        $f = 0
35        $r = StringReplace($r, '\"', '"')
36        Return $r
37EndFunc   ;==>__lastfm_send