Ich möchte ein Google Docs-Dokument in Haskell erstellen, so dass im Grunde möchte ich in Haskell, was dieses kleine C# Programm zu tun hat (von einem Google-Beispielprogramm angepasst):Wie lade ich ein Dokument von Google Docs in Haskell hoch?
using Google.GData.Documents;
using Google.GData.Client;
namespace DocListUploader
{
public class GDocConsole
{
static void Main()
{
var user = "...";
var passwd = "...";
var file = "...";
service = new DocumentsService("DocListUploader");
service.setUserCredentials(user, passwd);
service.UploadDocument(file, null);
}
}
}
Von der Google Docs API-Beschreibung here und diese SO Antwort here Ich verstand, es ist "nur" eine Frage von ein paar HTTP-POSTs zu senden und die OAuth-Authentifizierung getan, aber nur wie? Hat jemand das schon gemacht und hat einige Codebeispiele für mich ...?
EDIT: kann immer noch nicht herausfinden, wie die oauth Bibliotheken verwenden, so schrieb ich nur ein wenig C# Wrapper:
using Google.GData.Documents;
using Google.GData.Client;
public class GoogleDoc
{
public static int Upload(string user, string passwd, string file)
{
try
{
var service = new DocumentsService("DocListUploader");
service.setUserCredentials(user, passwd);
service.UploadDocument(file, null);
return 0;
}
catch
{
return -1;
}
}
}
und nannte diesen Wrapper von Haskell über hs-Dotnet:
module Upload where
import NET
upload :: String -> String -> String -> IO (Int)
upload user passed file =
invokeStatic "[GoogleDoc.dll]GoogleDoc" "Upload" (user, passed, file)
testLocal :: IO()
testLocal = do
let user = "..."
let passwd = "..."
let file = "..."
returnCode <- upload user passwd file
putStrLn (show returnCode)
Obwohl ich mit der Google Docs-API nicht vertraut bin, sollten Sie sich das [http-Paket auf Hackage] (http://hackage.haskell.org/package/HTTP) ansehen. –