Created
May 9, 2012 06:08
-
-
Save hewigovens/2642282 to your computer and use it in GitHub Desktop.
resolve short url
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <curl/curl.h> | |
int main(void) | |
{ | |
CURL *curl; | |
CURLcode ret; | |
char* resolved_url = NULL; | |
curl = curl_easy_init(); | |
if(curl) | |
{ | |
curl_easy_setopt(curl,CURLOPT_URL,"http://t.cn/zOHA0h2"); | |
curl_easy_setopt(curl,CURLOPT_FOLLOWLOCATION,1); | |
curl_easy_setopt(curl,CURLOPT_HEADER,1); | |
curl_easy_setopt(curl,CURLOPT_NOBODY,1); | |
curl_easy_setopt(curl,CURLOPT_TIMEOUT,5); | |
//curl_easy_setopt(curl,CURLOPT_PROXY,"127.0.0.1:8087"); | |
ret = curl_easy_perform(curl); | |
if(ret == 0 ) | |
{ | |
ret = curl_easy_getinfo(curl,CURLINFO_EFFECTIVE_URL,&resolved_url); | |
printf("resolve success\n"); | |
printf("resolved_url is %s",resolved_url); | |
} | |
else | |
{ | |
printf("resolve failed, error code is %d\n",ret); | |
} | |
curl_easy_cleanup(curl); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment