hat jemand für mich vielleicht ein Beispielcode, wie ich mit der libcurl und purebasic
ein Postfach über pop3 abfragen kann. Ich habe zwar einige Beispiele unter php gefunden,
jedoch hat irgendwie keines auf purebasic übertragen funktioniert.
PHP Beispielcode aus dem Netz.
Code: Alles auswählen
$curl = curl_init();
if($curl) {
/* Set username and password */
curl_setopt($curl, CURLOPT_USERNAME, "example@outlook.com");
curl_setopt($curl, CURLOPT_PASSWORD, "password");
curl_setopt($curl, CURLOPT_URL, "pop3://pop3.live.com");
curl_setopt($curl, CURLOPT_PORT, 995);
curl_setopt($curl, CURLOPT_USE_SSL,CURLUSESSL_ALL);
curl_setopt($curl, CURLOPT_CAINFO, "./certificate.pem");
curl_setopt($curl, CURLOPT_VERBOSE, true);
//return the transfer as a string
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
// $output contains the output string
$output = curl_exec($curl);
}
echo $output;
curl_close($curl);
curl über https post Daten an eine PHP Seite zu schicken.
Der Wrapper dazu kommt von: https://github.com/deseven/pbsamples/bl ... ibcurl.pbi
Code: Alles auswählen
xincludefile("libcurl.pbi")
Procedure.s posttest()
Protected werte.s = ""
Protected result.s = ""
; Beispielwerte für POST
werte + "&user=user"
werte + "&pw=passwort"
curl = curl_easy_init()
url.s = str2curl("https://webseite/test.php")
agent.s = str2curl("pbcurl/1.0")
post.s = str2curl(werte)
cookie.s = str2curl("var=value;")
header.s = str2curl("Cache-Control: no-cache")
If curl
curl_easy_setopt(curl, #CURLOPT_URL, @url)
curl_easy_setopt(curl, #CURLOPT_IPRESOLVE, #CURL_IPRESOLVE_V4)
curl_easy_setopt(curl, #CURLOPT_COOKIE, @cookie)
curl_easy_setopt(curl, #CURLOPT_POSTFIELDS, @post)
curl_easy_setopt(curl, #CURLOPT_USERAGENT, @agent)
curl_easy_setopt(curl, #CURLOPT_TIMEOUT, 30)
curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYPEER, 0)
curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYHOST, 0)
*header = curl_slist_append(0, header)
curl_easy_setopt(curl, #CURLOPT_HTTPHEADER, *header)
curl_easy_setopt(curl, #CURLOPT_WRITEFUNCTION, @curlWriteData())
res = curl_easy_perform(curl)
resData.s = curlGetData()
curl_easy_getinfo(curl, #CURLINFO_RESPONSE_CODE, @resHTTP)
If Not res
curl_easy_cleanup(curl)
ProcedureReturn resData
EndIf
curl_easy_cleanup(curl)
Else
MessageRequester("Hinweis", "Kann CURL nicht initialisieren!")
EndIf
EndProcedure
Debug posttest()
Uwe