如何使用BlackBerry Native Library在C ++中复制此类功能?
$username="admin";
$password="admin";
$url="http://www.yourdomain.com/";
$cookie="cookie.txt";
$postdata = "log=". $username ."&pwd=". $password ."&wp-submit=Log%20In&redirect_to=".
$url ."wp-admin/&testcookie=1";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url . "wp-login.php");
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt ($ch, CURLOPT_REFERER, $url . "wp-admin/");
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);
curl_close($ch);
echo $result;
exit;
BlackBerry Native Library中的“请求”通常类似于以下示例:
QNetworkAccessManager* networkAccessManager = new QNetworkAccessManager(this);
const QString queryUri = QString::fromLatin1("http://website.com/get.php?email=%1").arg(email);
QNetworkRequest request(queryUri);
QNetworkReply* reply = networkAccessManager->get(request);
任何信息或正确方向的观点都将是惊人的!
libcurl在BB10上可用,并且已经在sdk中。别忘了添加LIBS += -lcurl
到您的.pro
文件中
他们的网站上有很多示例。除了可以从PHP代码很好地转换的一些选项外,它几乎应该像那样。
#include <stdio.h>
#include <curl/curl.h>
int main(void)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
/* example.com is redirected, so we tell libcurl to follow redirection */
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
/* Check for errors */
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
/* always cleanup */
curl_easy_cleanup(curl);
}
return 0;
}
QString
s隐藏所有低级内容。将数据转换为时会感到痛苦char*
。用întèrnâtioñal数据进行测试。QNetworkAccessManager
和他的朋友使用完全不同的异步API。期望使libcurl发挥更大的痛苦。虽然有一些收获:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句