Код:
#include <Array.au3>
#include <IE.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Auth key parser", 268, 114, 192, 114)
$Get = GUICtrlCreateButton("Get key!", 8, 80, 251, 25)
GUICtrlSetFont(-1, 14, 400, 0, "Arial")
$Auth_key = GUICtrlCreateInput("Auth_key", 136, 40, 121, 21)
$App_id = GUICtrlCreateInput("App_id", 136, 8, 121, 21)
$Label1 = GUICtrlCreateLabel("Application ID:", 8, 8, 127, 26)
GUICtrlSetFont(-1, 14, 400, 0, "Arial")
$Label2 = GUICtrlCreateLabel("Auth key", 8, 40, 76, 26)
GUICtrlSetFont(-1, 14, 400, 0, "Arial")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Get
_Get()
EndSwitch
WEnd
Func _Get()
$Appid = GUICtrlRead($Auth_key)
$aA =_VK_SignIn($Appid,8192, 'http://oauth.vk.com/blank.html', 'wap')
$AccessToken=$aA[1]
GUICtrlSetData(-6,$aA[1])
EndFunc
#region Internal Functions
Func _VK_SignIn($iAppID, $sScope, $sRedirect_uri = "http://oauth.vk.com/blank.html", $sDisplay = "wap", $sResponse_type = "token")
Local $sOAuth_url = "https://oauth.vk.com/authorize?client_id=" & $iAppID & "&scope=" & $sScope & "&redirect_uri=" & $sRedirect_uri & "&display=" & $sDisplay & "&response_type=" & $sResponse_type
Return __guiAccessToken($sOAuth_url, 'Приложение запрашивает доступ', $sRedirect_uri)
EndFunc
Func __guiAccessToken($_sURI, $_sGUITitle, $_sRedirect_uri)
Local $oIE = _IECreateEmbedded()
Local $hTimer = TimerInit()
$_hATgui = GUICreate($_sGUITitle, 400, 300, -1, -1, $WS_SYSMENU)
GUICtrlCreateObj($oIE, 5, 5, 385, 260)
_IENavigate($oIE, $_sURI)
$sResponse = _IEBodyReadText($oIE)
If StringInStr($sResponse, "Login success") Then
$sURL = _IEPropertyGet($oIE, "locationurl")
Return __responseParse($sURL)
EndIf
GUISetState(@SW_SHOW)
While 1
If GUIGetMsg()=$GUI_EVENT_CLOSE Then
Exit
ElseIf TimerDiff($hTimer) > 50 Then
$sURL = _IEPropertyGet($oIE, "locationurl")
;~ ConsoleWrite($sURL & @LF)
If StringInStr($sURL, 'user_id=') Then
GUISetState(@SW_HIDE)
GUIDelete($_hATgui)
Return __responseParse($sURL)
ElseIf StringInStr($sURL,'error') Or StringInStr($sURL,'cancel') Then
Exit
EndIf
$hTimer = TimerInit()
EndIf
WEnd
EndFunc
Func __responseParse($_sResponse)
Local $aNArray = StringSplit($_sResponse, "&"), $aResArray[UBound($aNArray)]
$aResArray[0] = UBound($aNArray)-1
For $i = 1 To $aNArray[0]
$_sStr = StringSplit($aNArray[$i], "=")
$aResArray[$i] = $_sStr[2]
Next
;~ _ArrayDisplay($aResArray)
Return $aResArray
EndFunc
Func _CreateArray($sString, $sCodeWord)
Dim $aRetArray
$aRetArray = StringRegExp($sString, "<" & $sCodeWord & ">(.*?)</" & $sCodeWord & ">", 3)
Return $aRetArray
EndFunc ;==>_CreateArray
Скажите,что я неправильно делаю?