Last active
August 29, 2015 14:22
-
-
Save gregyjames/d4b910b0e02602af967b to your computer and use it in GitHub Desktop.
Return JSON with libcurl.net
This file contains hidden or 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
public static void Main(String[] args) | |
{ | |
try { | |
Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL); | |
Easy easy = new Easy(); | |
Easy.WriteFunction wf = new Easy.WriteFunction(OnWriteData); | |
easy.SetOpt(CURLoption.CURLOPT_URL, args[0]); | |
easy.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION, wf); | |
easy.Perform(); | |
easy.Cleanup(); | |
Curl.GlobalCleanup(); | |
} | |
catch(Exception ex) { | |
Console.WriteLine(ex); | |
} | |
} | |
public static Int32 OnWriteData(Byte[] buf, Int32 size, Int32 nmemb, | |
Object extraData) | |
{ | |
Console.Write(System.Text.Encoding.UTF8.GetString(buf)); | |
return size * nmemb; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment