Jump to content

Recommended Posts

hi, i send parameter to api and return value from InetRead like this:

Local $d__Data = InetRead("http://domain.com/api.php?ApiKey=125480054&Product=" & $M_License")
Local $i__BytesRead = @extended
Local $s__Data = BinaryToString($d__Data, $SB_UTF8)
MsgBox($MB_SYSTEMMODAL, "", "The number of bytes read: " & $i__BytesRead & @CRLF & @CRLF & $s__Data)

my return value have arabic caracter and i fix that from $SB_UTF8

now my problem is that, some times most i send arabic caracter to api and just i most use from inet command for send to api but when i use from InetRead for send arabic and english caracters to api, i see the arabic texts set in database like: ?????????????

i how can send arabic texts to api with InetRead command whitout broken text?

local $Send_To_API = "http://domain.ir/api.php?ApiKey=96307850859&Product=" & $M_License & "
F_Name=رضا&L_Name=یوسفی"
Local $s__Return = InetRead($Send_To_API)

datebase F_Name is set: ???
database L_Name is set: ?????

 

Link to post
Share on other sites

Have you tried URL encoding your URL or at least the values of the parameters that you are passing? 

The topic below is just one of many discussions that provides a solution.  The example below uses the functions in that topic with your URL.

 

#include <Constants.au3>

Global $gsUnicodeValue = "http://domain.ir/api.php?ApiKey=96307850859&Product=Whatever&F_Name=رضا&L_Name=یوسفی"
Global $gsEncodedValue = _UnicodeURLEncode($gsUnicodeValue)
Global $gsDecodedValue = _UnicodeURLDecode($gsEncodedValue)

MsgBox($MB_ICONINFORMATION + $MB_TOPMOST, _
       "INFO", _
       "Unicode value: " & $gsUnicodeValue & @CRLF & @CRLF & _
       "Encoded value: " & $gsEncodedValue & @CRLF & @CRLF & _
       "Decoded value: " & $gsDecodedValue _
       )

;===============================================================================
; _UnicodeURLEncode()
; Description: : Encodes an unicode string to be URL-friendly
; Parameter(s): : $UnicodeURL - The Unicode String to Encode
; Return Value(s): : The URL encoded string
; Author(s): : Dhilip89
; Note(s): : -
;
;===============================================================================

Func _UnicodeURLEncode($UnicodeURL)
    $UnicodeBinary = StringToBinary ($UnicodeURL, 4)
    $UnicodeBinary2 = StringReplace($UnicodeBinary, '0x', '', 1)
    $UnicodeBinaryLength = StringLen($UnicodeBinary2)
    Local $EncodedString
    For $i = 1 To $UnicodeBinaryLength Step 2
        $UnicodeBinaryChar = StringMid($UnicodeBinary2, $i, 2)
        If StringInStr("$-_.+!*'(),;/?:@=&abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", BinaryToString ('0x' & $UnicodeBinaryChar, 4)) Then
            $EncodedString &= BinaryToString ('0x' & $UnicodeBinaryChar)
        Else
            $EncodedString &= '%' & $UnicodeBinaryChar
        EndIf
    Next
    Return $EncodedString
EndFunc   ;==>_UnicodeURLEncode

;===============================================================================
; _UnicodeURLDecode()
; Description: : Tranlates a URL-friendly string to a normal string
; Parameter(s): : $toDecode - The URL-friendly string to decode
; Return Value(s): : The URL decoded string
; Author(s): : nfwu, Dhilip89
; Note(s): : Modified from _URLDecode() that's only support non-unicode.
;
;===============================================================================
Func _UnicodeURLDecode($toDecode)
    Local $strChar = "", $iOne, $iTwo
    Local $aryHex = StringSplit($toDecode, "")
    For $i = 1 To $aryHex[0]
        If $aryHex[$i] = "%" Then
            $i = $i + 1
            $iOne = $aryHex[$i]
            $i = $i + 1
            $iTwo = $aryHex[$i]
            $strChar = $strChar & Chr(Dec($iOne & $iTwo))
        Else
            $strChar = $strChar & $aryHex[$i]
        EndIf
    Next
    $Process = StringToBinary (StringReplace($strChar, "+", " "))
    $DecodedString = BinaryToString ($Process, 4)
    Return $DecodedString
EndFunc   ;==>_UnicodeURLDecode

 

Edited by TheXman
Link to post
Share on other sites

thanks TheXman

i have another problem

i use from _UnicodeURLEncode and problem with Arabic words solved

but if i compile and run exe , then return value from server is wrong. server return:

{"status":"1"}

but if i run script with double click on script then return values is true like:

{
           "status":"2"
          ,"country":"xx xx"
          ,"city":"xx xx"
          ,"f_name":"رضا"
          ,"l_name":"یوسفی نیا"
          ,"company":"رز سافت"
          ,"phone":"xx"
          ,"mail":"gmail.@gmail.com"
          ,"note":"تست مشکل عدم ارتباط"
 }

 

what is problem?!

Edited by r2du-soft
Link to post
Share on other sites

I am not going to try to guess what the problem is.  Either show your code or a small script that reproduces the issue.

Link to post
Share on other sites
On 7/8/2020 at 4:37 PM, TheXman said:

I am not going to try to guess what the problem is.  Either show your code or a small script that reproduces the issue.

  

On 7/8/2020 at 4:37 PM, TheXman said:

I am not going to try to guess what the problem is.  Either show your code or a small script that reproduces the issue.

thanks TheXman

the problem is solved after i testing again after 24 hours later,i think something the problem is from cache !

However problem is solved.

And the last question, Whether using $INET_FORCERELOAD cache is refreshed?

What is the best parameter to use in InetRead  ?

if i use from $INET_FORCERELOAD , if the program Proxifire is in running, InetRead can not return any data! and if i remove $INET_FORCERELOAD from end of InetRead command then i can give return value from server whit InetRead !!

I just want:

1- Use InetRead without cache problem
2- If users use from any proxy Then communication with the server is done right
3- Also the received (return) value from server should be correct

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.

×
×
  • Create New...