Passsage de parametre en http et VB6

morbak01 Messages postés 25 Date d'inscription lundi 17 juillet 2006 Statut Membre Dernière intervention 23 mars 2012 - 31 oct. 2008 à 11:20
PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 - 1 nov. 2008 à 13:52
Bonjour,

Ca fait un petit moment que je cherche et je galere toujours, voilà le pb:
J'ai un soft en VB6 qui doit passer des parametres à mon site, une page en php. L'url de passage de parametre et du style:
toto.fr/maj.php?v=parametres
En retour la page php renvoi "1" si tout s'est bien passé ou "0" si une erreur s'est produite.

J'ai d'abord utlisé le controle Webbrowser, mais je n'arrive pas a récupérer le trame de retour.
J'utilise aussi le controle Inet pour d'autres transferts FTP (fonction correctement).

L'idéal serait d'utiliser le controle Inet mais je n'y suis pas arrivé pour mon passage de variable.

Est-ce que qq1 aurait une idée, une source ou autre.

merci,

1 réponse

PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 47
1 nov. 2008 à 13:52
salut,

si ta page est du type toto.fr/maj.php?v= parametres, ton passage de paramètres est donc par GET, dons aucun souci pour envoyer ces paramètres....., il faut juste construite ton url avant de lancer INet

ensuite tu récupères la source de la page, qui contiendra ton 0 ou 1 si j'ai bien compris

PAR INET
<hr />
'     TÉLÉCHARGER UN FICHIER PAR INET
'    http://www.codyx.org/snippet_telecharger-fichier-inet_30.aspx#91
'    Posté par [ =401740 PCPT ] le 22/03/2006
<hr />
Private
 Sub Command1_Click()  
'   source
    Dim sUrl As String  
    sUrl  =  "http://blogs.developpeur.org/images/blogs_developpe"
& _
          
"ur_org/nix/491/o_CodyxWallpaper6.jpg"  

'   destination (app.path + nom du fichier distant)
    Dim sDest As String  
    sDest =  App.Path  
    If RightB$(sDest, 2) <> "" Then sDest = sDest & "" 
    sDest = sDest & Right$(sUrl, Len(sUrl) - InStrRev(sUrl, "/")) 

'   download
    Dim aBytes() As Byte, FF As Integer  
    With Inet  
        .AccessType = icUseDefault  
        .Protocol = icHTTP  
        aBytes = .OpenURL(sUrl, icByteArray)  
        Do Until Not (.StillExecuting)  
           DoEvents  
        Loop  
    End With  

'   écriture disque
    FF = FreeFile  
    Open sDest For Binary Access Write As FF  
        Put #FF, , aBytes()  
    Close FF  

    Erase aBytes  
    MsgBox "Terminé"  
End Sub

PAR API
<hr />
'    RÉCUPÉRER LA SOURCE D'UNE PAGE DANS UNE VARIABLE STRING PAR
API
'    http://www.codyx.org/snippet_recuperer-source-page-dans-variable-string-api_620.aspx#1877
'    Posté par [ PCPT ] le 09/06/2008
<hr />
Private Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" (ByVal lpFileName As String) As Long
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As
Long
 
Function GetStringSourceFromOnlineFile(ByVal
sUrl As String) As String
'   récupère un nom de fichier temporaire
    Dim sTempDest As String
    sTempDest  = GetUniqueTempFileName '
http://www.codyx.org/snippet_generer-nom-fichier-temporaire-unique_619.aspx#1876
'   télécharge la page
     If URLDownloadToFile(0&, sUrl, sTempDest, 0&, 0&) = 0
Then
'       on lit le
fichier
        Dim FF As Integer
        FF = FreeFile
        Open sTempDest For Input As #FF
            GetStringSourceFromOnlineFile = Input(LOF(FF), 1)
        Close #FF
'       supprime le fichier temp
        Call DeleteFile(sTempDest)
     End If
End Function

'----------------------------------------------------------------
'Remarques :
'Label1.AutoSize = True
'Label1.Caption = "Mon IP WAN : " &
GetStringSourceFromOnlineFile("http://www.whatismyip.org")
'
'
'
'nécessite
ce snippet :
http://www.codyx.org/snippet_generer-nom-fichier-temporaire-unique_619.aspx#1876

encore PAR API
<hr />
'     TÉLÉCHARGER UN FICHIER PAR API
'    http://www.codyx.org/snippet_telecharger-fichier-api_29.aspx#90
'    Posté par [ =401740 PCPT ] le 22/03/2006
<hr />
Option
 Explicit 

Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" _ 
            (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, _ 
             ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long 

Private Sub Form_Load() 
'   source
    Const
sUrl As String =
"http://www.vbfrance.com/gfx/logos/logovb.gif

'   destination (app.path + nom du fichier distant)
    Dim sDest As String 
    sDest =  App.Path 
    If RightB$(sDest, 2) <> "" Then
   
    sDest = sDest & "" 
    End
If
    sDest = sDest & Mid$(sUrl, 1 +InStrRev(sUrl, "/")) 

'   download
    If URLDownloadToFile(0&, sUrl, sDest, 0&, 0&) = 0 Then 
        MsgBox "Fichier téléchargé :" & vbNewLine
& sDest, vbInformation, "Réussite" 
    Else 
        MsgBox "Erreur lors du téléchargement", vbExclamation, "Echec" 
    End If 
End Sub

BOITE DE DIALOGUE
<hr />
'    TÉLÉCHARGER UN FICHIER APRÈS OUVERTURE DE LA BOITE DE DIALOGUE
SAVEAS
'    http://www.codyx.org/snippet_telecharger-fichier-apres-ouverture-boite-dialogue-saveas_684.aspx#2036
'    Posté par [ PCPT ] le 02/09/2008
<hr />
Private Declare Function DoFileDownload Lib "shdocvw.dll" (ByVal lpszFile As String) As Long
Public Sub DisplayDownloadBox(ByVal sPath As String)
    Call DoFileDownload(StrConv(sPath, vbUnicode))
End Sub

'APPEL :
Call DisplayDownloadBox("http://www.vbfrance.com/g/v9logo/logovb.gif")

'----------------------------------------------------------------
'Remarques :
'API non-documentée, notez que l'appel à la fonction lancera la
demande d'autorisation du parefeu

etc...., c'est pas le choix qui manque....
++

<hr size ="2" width="100%" />Prenez un instant pour répondre à [forum/sujet-SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp 
0
Rejoignez-nous