Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 得到回应_C_Curl_Libcurl - Fatal编程技术网

C 得到回应

C 得到回应,c,curl,libcurl,C,Curl,Libcurl,我发现cURL文档需要阅读/理解。我想在这里做的是发布一个邮政编码,然后返回它是否有效。 这是我目前为止的功能(我从教程中收集到的) 脚本返回“是”或“否”。 我只是不知道该在if语句中输入什么才能得到结果 提前感谢:)。听起来您想从服务器读取响应。为此,您需要启用选项CURLOPT\u READFUNCTION,并指定一个回调,该回调将从网络接收数据,并将其存储在char数组中。有关调用外观的进一步帮助,请参阅它只是curl\u easy\u setopt的一个参数?是,但是当您设置它时,您还

我发现cURL文档需要阅读/理解。我想在这里做的是发布一个邮政编码,然后返回它是否有效。 这是我目前为止的功能(我从教程中收集到的)

脚本返回“是”或“否”。 我只是不知道该在if语句中输入什么才能得到结果


提前感谢:)。

听起来您想从服务器读取响应。为此,您需要启用选项
CURLOPT\u READFUNCTION
,并指定一个回调,该回调将从网络接收数据,并将其存储在
char

数组中。有关调用外观的进一步帮助,请参阅它只是curl\u easy\u setopt的一个参数?是,但是当您设置它时,您还需要传递(您编写的)函数名来处理传入的数据。
int checkPostCode(char postCode[5])
{
    printf("checkPostCode\n");

    char uidPath[200] = "http://zim.cs.uow.edu.au/~dfs/cgi-bin/postcodes.cgi?pcode=";
    //Concatinate poth strings
    strcat (uidPath,postCode);
    //Output URl
    printf("%s \n ", uidPath);

    CURL *curl;
    CURLcode res;

    // Create our curl handle  
        curl = curl_easy_init();

    if (curl)  
        {  
        curl_easy_setopt(curl, CURLOPT_URL, uidPath);
        res = curl_easy_perform(curl);

        /* always cleanup */ 
        curl_easy_cleanup(curl);
    }

    return 0;
}