Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Restful API
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Applications Internet
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01576581
Message ID:
01576834
Vues:
54
>Since you know .NET then you could handle this with a HttpWebRequest in a DLL and expose it as a COM object to VFP ?

That's not really necessary. The client end of things from FoxPro is fairly easy and you can easily consume RESTful APIs from FoxPro using WinInet or WinHttp - or the West Wind wwHttp class (which wraps WinInet).

Calling into .NET for HTTP requests is pretty much overkill, and the HttpWebRequest object is a pain anyway and reqiures its own wrapping to reliably support POST operations and things like GZip etc.

+++ Rick ---

>
>Update: The first code snippet here is pretty much it : http://msdn.microsoft.com/en-us/magazine/ee309509.aspx
>
>>Hi,
>>
>>I have been asked to use a restful API (I believe that's what it's called to retrieve and post files to a folder on the web - or in the cloud as is the common term now).
>>
>>How do I do this from VFP?
>>
>>I have been given the following information:
>>
>>Viewing:
>>
>>To view a document simply go to the following URL. It will output a pdf file.
>>
>>http://***.***.***.***/api/index.php/documents/index/
>>
>>Example of a live document:
>>
>>http://***.***.***.***/api/index.php/documents/index/8CF8797D-4FDF-7A4C-3750-4C8BFF1A4BC4
>>
>>Uploading:
>>
>>To upload a file you have to do a HTTP POST to this URL:
>>
>>http://***.***.***.***/api/index.php/claims/upload
>>
>>It expects 2 parameters:
>>
>>doc_pk - the primary key for the field in the ClaimDocuments table which holds the description etc on the document
>>pdf - this should be a base64 encoded string of the contents of the file to upload
>>
>>This is a sample of the code I use to upload a document:
>>
>>$response = $this->rest->post('claims/upload', array(
>>'doc_pk'=> $doc_pk,
>>'pdf' => base64_encode(file_get_contents('resources/img/doctors.jpg'))
>>), 'json');
>>
>>As you can see I first read the contents of the file, then encode it, then send it to the RESTful server.
>>
>>The server will return a response in JSON. This is the php dump of that response:
>>
>>stdClass Object
>>(
>>[error] => false
>>[message] => File uploaded successfully.
>>)
>>
>>The error variable will be true or false. The message will correspond to the error state.
>>
>>To force an error you can POST to the URL with no variables.
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform