Raised This Month: $ Target: $400
 0% 

CURL Help


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
lexzor
Veteran Member
Join Date: Nov 2020
Old 05-12-2021 , 06:29   Re: CURL Help
Reply With Quote #6

Every time i get another output, but in console because i can t write the file.

PHP Code:
#include <amxmodx>
#include <curl>

#define CURL_BUFFER_SIZE 4096

public plugin_init()
{
    
register_plugin("CURL Test""1.0""-");

    
set_task(0.1"curl_test")
}

public 
curl_test()
{
    new 
szCURL_url[128]
    new 
CURL:cURLHandle
    
new data[1]
    
data[0] = fopen("addons/amxmodx/data/test.txt""wb")

    
formatex(szCURL_urlcharsmax(szCURL_url), "https://lexzor.warface.ro/AutoUpdate/Test/version.txt")

    
cURLHandle curl_easy_init()

    if(
cURLHandle)
    {
        
curl_easy_setopt(cURLHandleCURLOPT_BUFFERSIZECURL_BUFFER_SIZE)
        
curl_easy_setopt(cURLHandleCURLOPT_URLg_CURL_URL)
        
curl_easy_setopt(cURLHandleCURLOPT_WRITEDATAdata[0])
        
curl_easy_setopt(cURLHandleCURLOPT_WRITEFUNCTION"write" )
        
curl_easy_perform(cURLHandle"complite"datasizeof(data))
        
server_print("%i"data[0])
    }
}

public 
write (data[], sizenmembfile)
{
   new 
actual_size size nmemb;
   
// server_print("%i", actual_size)
   
fwrite_blocks(filedataactual_sizeBLOCK_CHAR)
  
// server_print("%s : %s", file, data)
   
return actual_size
}

public 
complite(CURL:curlCURLcode:codedata[])
{
  if(
code == CURLE_WRITE_ERROR)
     
server_print("transfer aborted")
  else
     
server_print("curl complete")
  
  
fclose(data[0])

  
curl_easy_cleanup(curl)


Last edited by lexzor; 05-12-2021 at 06:30.
lexzor is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:29.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode