Jump to content

Recommended Posts

goodmorning autoit team

today am comming with some winhttp problems, i hope that you can help me to solve them.

the first problem

is when opening a request

my forums api allow me to delete any post using the api key

all functions work, i mean post / get

but when i tried to use the delete verb it's gave me an html 404 error

here is what am tried

#include "WinHttp.au3"

; Open needed handles
Global $hOpen = _WinHttpOpen()
Global $hConnect = _WinHttpConnect($hOpen, "xxxxxxxx.com")
; Specify the reguest:

Global $hRequest = _WinHttpOpenRequest($hConnect, "Delete", "/vb/Api/posts/10447/?hard_delete=true", default, default)
_WinHttpAddRequestHeaders($hRequest, "XF-Api-Key:xxxxx")
_WinHttpAddRequestHeaders($hRequest, "XF-Api-User:xxxxx")

; Send request
_WinHttpSendRequest($hRequest)

; Wait for the response
_WinHttpReceiveResponse($hRequest)

Global $sHeader = 0, $sReturned = 0
; If there is data available...
If _WinHttpQueryDataAvailable($hRequest) Then 
$sHeader = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_CONTENT_DISPOSITION)
;Or maybe:
; $sHeader = _WinHttpQueryHeaders($hRequest, BitOR($WINHTTP_QUERY_RAW_HEADERS_CRLF, $WINHTTP_QUERY_CUSTOM), "Content-Disposition")

    Do
        $sReturned &= _WinHttpReadData($hRequest)
    Until @error
msgBox(64, "", $sReturned)
endIf


; Close handles
_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

 

and here is the error message

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /vb/Api/posts/10447/
on this server.<br />
</p>
</body></html>

 

i hope you can help me 

thanks in advance

Link to post
Share on other sites

so,
@Jos
when i use Post verb or Get it work
e.g here is the result when i use the same example with the Get command
 

{
    "post": {
        "attach_count": 0,
        "can_edit": true,
        "can_hard_delete": true,
        "can_react": true,
        "can_soft_delete": true,
        "can_view_attachments": true,
        "is_first_post": false,
        "is_last_post": true,
        "is_reacted_to": false,
        "last_edit_date": 1593265281,
        "message": "\u0627\u0644\u0633\u0644\u0627\u0645 \u0639\u0644\u064a\u0643\u0645 \u0645\u0648\u0636\u0648\u0639 \u062c\u0645\u064a\u0644 \u0628\u0627\u0631\u0643 \u0627\u0644\u0644\u0647 \u0641\u064a\u0643 \u064a\u0627 \u062d\u0648\u062f\u0649",
        "message_state": "visible",
        "position": 5,
        "post_date": 1593264635,
        "post_id": 10447,
        "reaction_score": 0,
        "Thread": {
            "BaUser": null,
            "can_edit": true,
            "can_edit_tags": true,
            "can_hard_delete": true,
            "can_reply": true,
            "can_soft_delete": true,
            "can_view_attachments": true,
            "custom_fields": {},
            "discussion_open": true,
            "discussion_state": "visible",
            "discussion_type": "",
            "first_post_id": 10289,
            "first_post_reaction_score": 3,
            "Forum": {
                "breadcrumbs": [
                    {
                        "node_id": 48,
                        "title": "\u0627\u0644\u0642\u0633\u0645 \u0627\u0644\u0639\u0627\u0645",
                        "node_type_id": "Category"
                    }
                ],
                "description": "",
                "display_in_list": true,
                "display_order": 100,
                "node_id": 49,
                "node_name": null,
                "node_type_id": "Forum",
                "parent_node_id": 48,
                "title": "\u0627\u0644\u0645\u0646\u062a\u062f\u0649 \u0627\u0644\u0639\u0627\u0645",
                "type_data": {
                    "allow_poll": true,
                    "allow_posting": true,
                    "can_create_thread": true,
                    "can_upload_attachment": true,
                    "discussion_count": 85,
                    "last_post_date": 1593264635,
                    "last_post_id": 10447,
                    "last_post_username": "MesterPerfect",
                    "last_thread_id": 4884,
                    "last_thread_prefix_id": 0,
                    "last_thread_title": "\u0645\u0627 \u0647\u0648 \u0645\u0641\u0647\u0648\u0645 \u0627\u0644\u0623\u0645\u0646 \u0627\u0644\u0633\u064a\u0628\u0631\u0627\u0646\u064a",
                    "message_count": 172,
                    "min_tags": 0,
                    "require_prefix": false
                }
            },
            "is_watching": true,
            "last_post_date": 1593264635,
            "last_post_id": 10447,
            "last_post_user_id": 2,
            "last_post_username": "MesterPerfect",
            "node_id": 49,
            "post_date": 1592577213,
            "prefix_id": 0,
            "reply_count": 5,
            "sticky": false,
            "tags": [
                "\u0625\u0644\u0649",
                "\u0627\u0644\u0623\u0645\u0646",
                "\u0627\u0644\u0633\u064a\u0628\u0631\u0627\u0646\u064a",
                "\u0627\u0644\u0645\u0639\u0644\u0648\u0645\u0627\u062a",
                "\u0639\u0644\u0649"
            ],
            "thread_id": 4884,
            "title": "\u0645\u0627 \u0647\u0648 \u0645\u0641\u0647\u0648\u0645 \u0627\u0644\u0623\u0645\u0646 \u0627\u0644\u0633\u064a\u0628\u0631\u0627\u0646\u064a",
            "User": {
                "activity_visible": true,
                "age": 21,
                "avatar_urls": {
                    "o": null,
                    "h": null,
                    "l": null,
                    "m": null,
                    "s": null
                },
                "can_ban": false,
                "can_converse": true,
                "can_edit": true,
                "can_follow": true,
                "can_ignore": true,
                "can_post_profile": true,
                "can_view_profile": true,
                "can_view_profile_posts": true,
                "can_warn": false,
                "custom_fields": {
                    "facebook": "mahmoud.atef.000",
                    "gender": "male",
                    "screen_readers": "1",
                    "skype": "mahmoud.atef.000",
                    "twitter": "",
                    "windows": "4"
                },
                "custom_title": "",
                "dob": {
                    "year": 1999,
                    "month": 4,
                    "day": 4
                },
                "is_admin": true,
                "is_banned": false,
                "is_discouraged": false,
                "is_followed": false,
                "is_ignored": false,
                "is_moderator": false,
                "is_staff": false,
                "is_super_admin": true,
                "last_activity": 1593209942,
                "location": "\u0627\u0644\u0642\u0627\u0647\u0631\u0629",
                "message_count": 91,
                "reaction_score": 141,
                "register_date": 1533659760,
                "secondary_group_ids": [
                    3,
                    4
                ],
                "signature": "",
                "trophy_points": 93,
                "user_group_id": 2,
                "user_id": 6,
                "user_state": "valid",
                "user_title": "\u0639\u0636\u0648 \u0641\u0639\u0627\u0644",
                "username": "mahmoud.atef",
                "visible": true,
                "warning_points": 0,
                "website": "https://mx-blind.com"
            },
            "user_id": 6,
            "username": "mahmoud.atef",
            "view_count": 92,
            "visitor_post_count": 1
        },
        "thread_id": 4884,
        "User": {
            "activity_visible": true,
            "avatar_urls": {
                "o": "https://secure.gravatar.com/avatar/324bc0d4e2add5deec287b874280734d?s=384",
                "h": "https://secure.gravatar.com/avatar/324bc0d4e2add5deec287b874280734d?s=384",
                "l": "https://secure.gravatar.com/avatar/324bc0d4e2add5deec287b874280734d?s=192",
                "m": "https://secure.gravatar.com/avatar/324bc0d4e2add5deec287b874280734d?s=96",
                "s": "https://secure.gravatar.com/avatar/324bc0d4e2add5deec287b874280734d?s=48"
            },
            "can_ban": false,
            "can_converse": true,
            "can_edit": true,
            "can_follow": true,
            "can_ignore": false,
            "can_post_profile": true,
            "can_view_profile": true,
            "can_view_profile_posts": true,
            "can_warn": false,
            "custom_fields": {
                "facebook": "my.nvda.1",
                "gender": "male",
                "screen_readers": "1",
                "skype": "live:AhmedBakr012",
                "twitter": "my_nvda",
                "windows": "3",
                "Telegram": "MesterPerfect"
            },
            "custom_title": "",
            "dob": {
                "year": null,
                "month": 10,
                "day": 1
            },
            "is_admin": true,
            "is_banned": false,
            "is_discouraged": false,
            "is_followed": false,
            "is_ignored": false,
            "is_moderator": true,
            "is_staff": true,
            "is_super_admin": true,
            "last_activity": 1593268517,
            "location": "sohag, Egypt",
            "message_count": 3042,
            "reaction_score": 2073,
            "register_date": 1533539769,
            "secondary_group_ids": [
                3,
                4
            ],
            "signature": "[CENTER][SIZE=5]\u2022\u2022\u2022 \uf0d7 The Elimination Chamber is back\u2022\u2022\u2022 \uf0d7[/SIZE][/CENTER]\n[YOUTUBESUBSCRIBER]UC-JaR2UmCzOjz7TFPHS9YHg[/YOUTUBESUBSCRIBER]",
            "trophy_points": 595,
            "user_group_id": 2,
            "user_id": 2,
            "user_state": "valid",
            "user_title": "\u0627\u0644\u0648\u0633\u0627\u0645 \u0627\u0644\u0645\u0627\u0633\u064a",
            "username": "MesterPerfect",
            "visible": true,
            "warning_points": 0,
            "website": "https://mx-blind.com"
        },
        "user_id": 2,
        "username": "MesterPerfect",
        "warning_message": ""
    }
}

 

Link to post
Share on other sites
  • Developers

I removed my post earlier as I misread the error code....   but either way ...  there isn't much we can do unless we can test. the 403 is an access issue.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

Why are you asking what appears to be a XenForo Forum API related questions in an AutoIt forum?  Looking at the response to the DELETE API request that you posted earlier, you got back a 403 Forbidden response.  Given that your GET requests are successful, that probably means that either your API call is not correct or that the XF-Api-User does not have permission to delete the specified post.

Link to post
Share on other sites

Are you using a Super-User api-key?  I assume that you are because you supplied an api-user in the header.  If that user does not have permission to delete posts, that is why you are getting a 403 response.  If you want to bypass the user's context and delete the post as a super user, then you must do it on a per-request basis.  The following is taken from the API documentation:

If the request is made with a super user key and you wish to bypass the context user's permissions, this may be done on a per-request basis by setting the api_bypass_permissions parameter to 1. (This can be passed via a query string or as part of the request body.)

That information above can be found on the following page of the API doc:

https://xenforo.com/xf2-docs/dev/rest-api/

Edited by TheXman
Link to post
Share on other sites

the api key is a super key

i put an admin user

by the way i don't know how i can pass this param using winhttp, can you gid me to do that and test please?

note: when i tried to create e.g a new thread using a guest api key it gave me an error msg as json string told me that the api does not have the permitions to do that

Link to post
Share on other sites

Assuming that everything else in your script is correct, then you can try changing the follow line from:

Global $hRequest = _WinHttpOpenRequest($hConnect, "Delete", "/vb/Api/posts/10447/?hard_delete=true", default, default)

To

Global $hRequest = _WinHttpOpenRequest($hConnect, "Delete", "/vb/Api/posts/10447?hard_delete=true&api_bypass_permissions=1", default, default)

 

Link to post
Share on other sites

hello again,

i confermed that the problem from the xenforo api i conntacted them

now i have a small problem with json

i hope that i can find here a reply

i have this data

{
    "success": true,
    "conversation": {
        "can_edit": true,
        "can_invite": true,
        "can_reply": true,
        "can_upload_attachment": true,
        "conversation_id": 955,
        "conversation_open": true,
        "first_message_id": 1710,
        "is_starred": false,
        "last_message_date": 1593345206,
        "last_message_id": 1710,
        "last_message_user_id": 5,
        "open_invite": false,
        "recipient_count": 2,
        "recipients": {
            "2": "MesterPerfect"
        },
        "reply_count": 0,
        "start_date": 1593345206,
        "Starter": {
            "activity_visible": false,
            "avatar_urls": {
                "o": "https://mx-blind.com/vb/data/avatars/o/0/5.jpg?1534192853",
                "h": "https://mx-blind.com/vb/data/avatars/h/0/5.jpg?1534192853",
                "l": "https://mx-blind.com/vb/data/avatars/l/0/5.jpg?1534192853",
                "m": "https://mx-blind.com/vb/data/avatars/m/0/5.jpg?1534192853",
                "s": "https://mx-blind.com/vb/data/avatars/s/0/5.jpg?1534192853"
            },
            "can_ban": false,
            "can_converse": false,
            "can_edit": true,
            "can_follow": false,
            "can_ignore": false,
            "can_post_profile": true,
            "can_view_profile": true,
            "can_view_profile_posts": true,
            "can_warn": false,
            "custom_fields": {
                "facebook": "baaziznacer1",
                "gender": "male",
                "screen_readers": "2",
                "skype": "simple-blind",
                "twitter": "baaziznacer",
                "windows": "4"
            },
            "custom_title": "",
            "is_admin": true,
            "is_banned": false,
            "is_discouraged": false,
            "is_followed": false,
            "is_ignored": false,
            "is_moderator": true,
            "is_staff": true,
            "is_super_admin": true,
            "last_activity": 1593287145,
            "location": "\u0627\u0644\u062c\u0632\u0627\u0626\u0631",
            "message_count": 597,
            "reaction_score": 569,
            "register_date": 1533642994,
            "secondary_group_ids": [
                3,
                4
            ],
            "signature": "\u2022 \u0627\u0644\u062f\u0646\u064a\u0627 \u062b\u0644\u0627\u062b\u0629 \u0623\u064a\u0627\u0645: \u0627\u0644\u0623\u0645\u0633 \u0639\u0634\u0646\u0627\u0647 \u0648\u0644\u0646 \u064a\u0639\u0648\u062f\u060c \u0627\u0644\u064a\u0648\u0645 \u0646\u0639\u064a\u0634\u0647 \u0648\u0644\u0646 \u064a\u062f\u0648\u0645\u060c \u0648\u0627\u0644\u063a\u062f: \u0644\u0627 \u0646\u062f\u0631\u064a \u0623\u064a\u0646 \u0633\u0646\u0643\u0648\u0646 \u0641\u0635\u0627\u0641\u062d\u060c \u0648\u0633\u0627\u0645\u062d\u060c \u0648\u062f\u0639 \u0627\u0644\u062e\u0644\u0642 \u0644\u0644\u062e\u0627\u0644\u0642\u060c \u0641\u0623\u0646\u0627 \u0648\u0623\u0646\u062a \u0648\u0647\u0645 \u0648\u0646\u062d\u0646 \u0631\u0627\u062d\u0644\u0648\u0646\u060c \u0641\u0645\u0646 \u0623\u0639\u0645\u0627\u0642 \u0642\u0644\u0628\u0643 \u0633\u0627\u0645\u062d \u0645\u0646 \u0623\u0633\u0627\u0621 \u0625\u0644\u064a\u0643.",
            "trophy_points": 210,
            "user_group_id": 2,
            "user_id": 5,
            "user_state": "valid",
            "user_title": "\u0639\u0636\u0648 \u0645\u062d\u062a\u0631\u0641",
            "username": "\u0646\u0627\u0635\u0631 \u0628\u0639\u0632\u064a\u0632",
            "visible": true,
            "warning_points": 0,
            "website": "http://mx-blind.com/"
        },
        "title": "\u0623\u0646\u0627 \u0632\u0641\u062a",
        "user_id": 5,
        "username": "\u0646\u0627\u0635\u0631 \u0628\u0639\u0632\u064a\u0632"
    }
}

 

i need to decode it using json

can we do that using autoit?

because the utf8 text here is encoded

thanks in advance

Link to post
Share on other sites
  • Developers

This is an example script that will read your posted data from "data.txt" and then display 2 of the keys of which one is containing Unicode characters:

#include "Json.au3"
$data = FileRead("data.txt")
Json_dump($data)
$object = json_decode($data)
$register_date=json_get($object, '.conversation.Starter.register_date')
MsgBox(262144, 'Debug line ~' & @ScriptLineNumber, 'Selection:' & @CRLF & '$register_date' & @CRLF & @CRLF & 'Return:' & @CRLF & $register_date) ;### Debug MSGBOX
$signature=json_get($object, '.conversation.Starter.signature')
MsgBox(262144, 'Debug line ~' & @ScriptLineNumber, 'Selection:' & @CRLF & '$signature' & @CRLF & @CRLF & 'Return:' & @CRLF & $signature) ;### Debug MSGBOX

The json.au3 can be found here:  

 

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Danyfirex
      Hello guys.  I recently saw some posts that Windows 10 provides OCR API. So I decided to create a UDF.
       
       
      What's UWPOCR?
      UWPOCR UDF is a simple library to use Universal Windows Platform Optical character recognition API.
      Features.
      Get Text From Image File. Get Text From GDI+ Bitmap. Easy to use.  Usage:
      #include "..\UWPOCR.au3" _Example() Func _Example() Local $sOCRTextResult = _UWPOCR_GetText(FileOpenDialog("Select Image", @ScriptDir & "\", "Images (*.jpg;*.bmp;*.png;*.tif;*.gif)")) MsgBox(0,"",$sOCRTextResult) EndFunc Get Words Rect(Example):

       
      More examples here.
       
      Check UWPOCR UDF on GitHub.
       
      Saludos
    • By mLipok
      I try to download some file with winhttp.au3
      I use code from here:

      My code looks like:
      #include <FileConstants.au3> #include "WinHttp.au3" #AutoIt3Wrapper_Run_AU3Check=N _Example() Func _Example() ; Initialize and get session handle Local $hOpen = _WinHttpOpen() ; Get connection handle Local $hConnect = _WinHttpConnect($hOpen, "https://MY_URL") Local $CurrentOption = _WinHttpQueryOption($hConnect, $WINHTTP_OPTION_SECURITY_FLAGS) Local $Options = BitOR($CurrentOption, _ $SECURITY_FLAG_IGNORE_UNKNOWN_CA, _ $SECURITY_FLAG_IGNORE_CERT_CN_INVALID, _ $SECURITY_FLAG_IGNORE_CERT_DATE_INVALID) _WinHttpSetOption($hConnect, $WINHTTP_OPTION_SECURITY_FLAGS, $Options) If @error Then ConsoleWrite("! ---> @error=" & @error & " @extended=" & @extended & _ " : _WinHttpSetOption" & @CRLF) ; Specify the reguest Local $hRequest = _WinHttpOpenRequest($hConnect, Default, "MY_FILE") ; Send request _WinHttpSendRequest($hRequest) ; Wait for the response _WinHttpReceiveResponse($hRequest) ProgressOn("Downloading", "In Progress...") Progress(_WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_CONTENT_LENGTH)) Local $sData ; Check if there is data available... If _WinHttpQueryDataAvailable($hRequest) Then While 1 $sChunk = _WinHttpReadData_Ex($hRequest, Default, Default, Default, Progress) If @error Then ExitLoop $sData &= $sChunk Sleep(20) WEnd Else MsgBox(48, "Error", "Site is experiencing problems (or you).") EndIf Sleep(1000) ProgressOff() ; Close handles _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) Local $hFile = FileOpen(@ScriptDir & "\MY_FILE", $FO_OVERWRITE + $FO_CREATEPATH + $FO_BINARY) FileWrite($hFile, $sData) FileClose($hFile) EndFunc ;==>_Example Func Progress($iSizeAll, $iSizeChunk = 0) Local Static $iMax, $iCurrentSize If $iSizeAll Then $iMax = $iSizeAll $iCurrentSize += $iSizeChunk Local $iPercent = Round($iCurrentSize / $iMax * 100, 0) ProgressSet($iPercent, $iPercent & " %") EndFunc ;==>Progress Func _WinHttpReadData_Ex($hRequest, $iMode = Default, $iNumberOfBytesToRead = Default, $pBuffer = Default, $vFunc = Default) __WinHttpDefault($iMode, 0) __WinHttpDefault($iNumberOfBytesToRead, 8192) __WinHttpDefault($vFunc, 0) Local $tBuffer, $vOutOnError = "" If $iMode = 2 Then $vOutOnError = Binary($vOutOnError) Switch $iMode Case 1, 2 If $pBuffer And $pBuffer <> Default Then $tBuffer = DllStructCreate("byte[" & $iNumberOfBytesToRead & "]", $pBuffer) Else $tBuffer = DllStructCreate("byte[" & $iNumberOfBytesToRead & "]") EndIf Case Else $iMode = 0 If $pBuffer And $pBuffer <> Default Then $tBuffer = DllStructCreate("char[" & $iNumberOfBytesToRead & "]", $pBuffer) Else $tBuffer = DllStructCreate("char[" & $iNumberOfBytesToRead & "]") EndIf EndSwitch Local $sReadType = "dword*" If BitAND(_WinHttpQueryOption(_WinHttpQueryOption(_WinHttpQueryOption($hRequest, $WINHTTP_OPTION_PARENT_HANDLE), $WINHTTP_OPTION_PARENT_HANDLE), $WINHTTP_OPTION_CONTEXT_VALUE), $WINHTTP_FLAG_ASYNC) Then $sReadType = "ptr" Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpReadData", _ "handle", $hRequest, _ "struct*", $tBuffer, _ "dword", $iNumberOfBytesToRead, _ $sReadType, 0) If @error Or Not $aCall[0] Then Return SetError(1, 0, "") If Not $aCall[4] Then Return SetError(-1, 0, $vOutOnError) If IsFunc($vFunc) Then $vFunc(0, $aCall[4]) If $aCall[4] < $iNumberOfBytesToRead Then Switch $iMode Case 0 Return SetExtended($aCall[4], StringLeft(DllStructGetData($tBuffer, 1), $aCall[4])) Case 1 Return SetExtended($aCall[4], BinaryToString(BinaryMid(DllStructGetData($tBuffer, 1), 1, $aCall[4]), 4)) Case 2 Return SetExtended($aCall[4], BinaryMid(DllStructGetData($tBuffer, 1), 1, $aCall[4])) EndSwitch Else Switch $iMode Case 0, 2 Return SetExtended($aCall[4], DllStructGetData($tBuffer, 1)) Case 1 Return SetExtended($aCall[4], BinaryToString(DllStructGetData($tBuffer, 1), 4)) EndSwitch EndIf EndFunc ;==>_WinHttpReadData_Ex
      As a result I get file with this contents:
       
      As so far I found this:
        

      So I even with added:
      Local $CurrentOption = _WinHttpQueryOption($hConnect, $WINHTTP_OPTION_SECURITY_FLAGS) Local $Options = BitOR($CurrentOption, _ $SECURITY_FLAG_IGNORE_UNKNOWN_CA, _ $SECURITY_FLAG_IGNORE_CERT_CN_INVALID, _ $SECURITY_FLAG_IGNORE_CERT_DATE_INVALID) _WinHttpSetOption($hConnect, $WINHTTP_OPTION_SECURITY_FLAGS, $Options) If @error Then ConsoleWrite("! ---> @error=" & @error & " @extended=" & @extended & _ " : _WinHttpSetOption" & @CRLF)
      I still get the same errors.

      Anyone know a way how to fix this problem?

      Regards,
      mLipok
       
    • By mLipok
      This is TeamViewer.au3 UDF for TeamViewer API.
      ; #INDEX# ======================================================================== ; Title .........: TeamViewer.au3 ; AutoIt Version : 3.3.10.2++ ; Language ......: English ; Description ...: A collection of function for use with TeamViewer API ; Author ........: mLipok ; Modified ......: ; URL ...........: ; URL ...........: https://www.teamviewer.com/ ; URL ...........: https://www.teamviewer.com/en/integrations/ ; URL ...........: https://integrate.teamviewer.com/en/develop/api/get-started/ ; URL ...........: https://downloadeu1.teamviewer.com/integrate/TeamViewer_API_Documentation.pdf ; Remarks .......: This UDF was created based on TeamViewer_API_Documentation.pdf v 1.4.1 ; Remarks .......: This UDF is using Free Chilkat component look here https://www.autoitscript.com/forum/files/file/433-chilkat-udf/ ; Remarks .......: Documentation is "work in progress" ; Date ..........: 2017/02/08 ; Version .......: 0.1.1 BETA - Work in progress ; ================================================================================ in TeamViewer_Example.au3 you can see few examples:

       
      Func _Example() ; If not exist then create new INI file from template If Not FileExists('TeamViewer_Example.ini') Then FileCopy('TeamViewer_Example — Template.ini', 'TeamViewer_Example.ini') ; Read Access Token from INI Local $sTV_AccessToken = IniRead('TeamViewer_Example.ini', 'Settings', 'AccessToken', '') If $sTV_AccessToken = '' Then ; Your Access Token, can be left empty when OAuth (below) is configured. ; ClientId = <----------------- Create an app in your TeamViewer Management Console and insert the client ID to the INI ; ClientSecret = <------------- Insert your client secret to the INI ; AuthorizationCode = <-------- Visit https://webapi.teamviewer.com/api/v1/oauth2/authorize?response_type=code&client_id=YOUR$i_ClientIdHERE ; Login, grant the permissions (popup) and put the code shown in the AuthorizationCode variable to the INI Local $sTVOAuth_ClientID = IniRead('TeamViewer_Example.ini', 'OAuth2', 'ClientID', '') Local $sTVOAuth_ClientSecret = IniRead('TeamViewer_Example.ini', 'OAuth2', 'ClientSecret', '') _IECreate('https://webapi.teamviewer.com/api/v1/oauth2/authorize?response_type=code&client_id=' & $sTVOAuth_ClientID) ; Local $sTVOAuth_AuthorizationCode = IniRead('TeamViewer_Example.ini', 'OAuth2', 'authorizationCode', '') Local $sTVOAuth_AuthorizationCode = InputBox('AuthorizationCode', 'Please provide TV OAuth2 AuthorizationCode') If @error Then Return If $sTVOAuth_ClientID Then $sTV_AccessToken = _TVAPI_RequestOAuth2_AccessToken($sTVOAuth_ClientID, $sTVOAuth_ClientSecret, $sTVOAuth_AuthorizationCode) EndIf If $sTV_AccessToken Then _TVAPI_AccessToken($sTV_AccessToken) If _TVAPI_Ping() = True Then ; ping API to check connection and $sTV_AccessToken _Example_TeamViewer__1_Devices_SaveToFile() ;~ _Example_TeamViewer__2_Devices_ChangeDetails() ;~ _Example_TeamViewer__3_Devices_GetDevicesSingleID() ;~ _Example_TeamViewer__4_Reports_GetAllConnections() ;~ _Example_TeamViewer__5_Users_GetUserInfomation() ;~ _Example_TeamViewer__6_Groups_ListGroups() ;~ _Example_TeamViewer__7_Devices_AddDeleteDevice() Else MsgBox(0, '_TVAPI_Ping', "$v_Token or connection problem.") EndIf EndFunc ;==>_Example You can download it here:
      I'm using TeamViewer_Example.ini to store my secret tokens/keys.
      [Settings] AccessToken= [OAuth2] ClientID= ClientSecret= authorizationCode=  
    • By adityaparakh
      Hello ,
      I am trying to use Websockets in AutoIt.
      It is to fetch live stock market prices , API is provided and documentation available for python language.
      The link for the code snippet is :
      https://symphonyfintech.com/xts-market-data-front-end-api-v2/#tag/Introduction
      https://symphonyfintech.com/xts-market-data-front-end-api-v2/#tag/Instruments/paths/~1instruments~1subscription/post
       
      https://github.com/symphonyfintech/xts-pythonclient-api-sdk
       
      Second Link is to subscribe to a list of ExchangeInstruments.
      Now I would like to get live stock ltp (LastTradedPrice) for a few stocks whose "ExchangeInstrumentID" I know.
      I am able to use the WinHttp object to perform actions using simple codes like below :
      I have the secretKey and appkey and can generate the needed token. And get the unique ExchangeInstrumentID.

      Below code is just for example of how I am using WinHttp. Unrelated to socket part.
      Global $InteractiveAPItoken = IniRead(@ScriptDir & "\Config.ini", "token", "InteractiveAPItoken", "NA") $baseurl = "https://brokerlink.com/interactive/" $functionurl = "orders" $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("POST", $baseurl & $functionurl, False) $oHTTP.SetRequestHeader("Content-Type", "application/json;charset=UTF-8") $oHTTP.SetRequestHeader("authorization", $InteractiveAPItoken) $pD = '{ "exchangeSegment": "NSEFO", "exchangeInstrumentID": ' & $exchangeInstrumentID & ', "productType": "' & $producttype & '", "orderType": "MARKET", "orderSide": "' & $orderside & '", "timeInForce": "DAY", "disclosedQuantity": 0, "orderQuantity": ' & $qty & ', "limitPrice": 0, "stopPrice": 0, "orderUniqueIdentifier": "' & $orderidentifier & '"}' $oHTTP.Send($pD) $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status
          
          
      But am struggling to understand and use socket.
      Would be of great help if you can have a look at the link mentioned above and help with the code sample for AutoIt.
      To connect and listen to a socket.
      Thanks a lot
       
    • By nacerbaaziz
      hello guys, please i need your help
      am trying to work with CreateWindowEx api, i created the window with it controls, also i setup the call back function
      i'am using WinMSGLoop to focus with the keyboard.
      here i have a problem, i hope that you can help me.
      on the controls i used the UDF that comme with the autoit, such as _GUIButton_Create, _GUIListBox_Create....
      but i can't find a STATIC control UDF, for that i used this

      local $h_ssrvlbl = _WinAPI_CreateWindowEx(0, "STATIC", "الخادم", BitOr($WS_VISIBLE, $WS_CHILD, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN), 250, 10, 100, 20, $hWnd)
      as you can see here, there is an arabic text, so here is the problem, the arabic text isn't show normally, what is the problem here?
      also i have  an other question about keyboard focus, when i used WinMSGLoop, it worked, but if i press alt+tab to switch windows or focus an other window and return back to my window, the focus of control is kill.
      can any one help me to solve that please?
      my code will be as file here with the include files
      i hope can any one help me here
      thanks in advance
       
      speed Test win.zip
×
×
  • Create New...