Raised This Month: $51 Target: $400
 12% 

[EXTENSION] cURL & Hash


Post New Thread Reply   
 
Thread Tools Display Modes
Nano2e
SourceMod Donor
Join Date: Apr 2012
Location: Australia
Old 06-22-2013 , 11:08   Re: [EXTENSION] cURL & Hash
Reply With Quote #81

Has this ext stopped working? I can't seem to upload any files now.
__________________
Veni Vidi Vici
Nano2e is offline
neatek
AlliedModders Donor
Join Date: Jul 2010
Location: Russia
Old 07-24-2013 , 19:57   Re: [EXTENSION] cURL & Hash
Reply With Quote #82

how to get page content by using this extension?
__________________
neatek is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 10-08-2013 , 16:26   Re: [EXTENSION] cURL & Hash
Reply With Quote #83

Quote:
Originally Posted by Dr. Greg House View Post
I'd like to get the content of a webpage in order to parse it later on. Is there a way to get the page's text without having to buffer it in a file? Like downloading a webpage to a string variable and getting the length?
I am still trying to do this using this extension.
At the moment I am using CURLOPT_WRITEFUNCTION to detour the stream into my own callback writing this into a predefined string buffer (which is quite huge).
But now that I think about it I'm afraid there is a way easier way to get the whole webpage into a string, maybe using some call during "OnComplete"?
Anyone?
__________________
Santa or Satan?

Watch out when you're paying people for private requests! Most stuff already exists and you can hardly assess the quality of what you'll get, and if it's worth the money.

Last edited by Dr. Greg House; 10-08-2013 at 16:29.
Dr. Greg House is offline
ftopku
New Member
Join Date: Nov 2013
Old 11-08-2013 , 20:07   Re: [EXTENSION] cURL & Hash
Reply With Quote #84

I'm trying to send simple POST request and get response as string:
Code:
public makeReq()
{
    new Handle:curl = curl_easy_init();
    
    //new String:curl_post_params[512];
    //Format(curl_post_params, sizeof(curl_post_params), "apikey=%s&name=%s", KILL_API_KEY, KILL_API_KEY);
    
    if(curl != INVALID_HANDLE)
    {
        CURL_DEFAULT_OPT(curl);
        //curl_easy_setopt_handle(curl, CURLOPT_WRITEFUNCTION, mycallback);
        //curl_easy_setopt_int(curl, CURLOPT_CONNECT_ONLY, 1);
        //curl_easy_setopt_string(curl, CURLOPT_POSTFIELDS, curl_post_params);
        curl_easy_setopt_string(curl, CURLOPT_URL, "http://t.local/index.php");
        //curl_easy_setopt_int(curl, CURLOPT_PORT, 80);
        curl_easy_perform_thread(curl, ExecCURL);
        //ExecCURL(curl,5);
    } else {
        PrintCreatecUrlError(5);
    }
}

public ExecCURL(Handle:curl, CURLcode: code, any:data)
{
    if(curl != INVALID_HANDLE && code != CURLE_OK)
    {
        new String:error_buffer[256];
        curl_easy_strerror(code, error_buffer, sizeof(error_buffer));
        PrintTestCaseDebug(5, "FAIL - %s", error_buffer);
        CloseHandle(curl);
        return;
    }

    // (Handle:hndl, CURL_OnSend:send_callback, CURL_OnReceive:receive_callback, CURL_OnComplete:complete_callback, SendRecv_Act:act, send_timeout, recv_timeout, recv_buffer_Size = 1024, any:value=0);
    //(curl, OnReceive, current_test);
    curl_easy_send_recv(curl, OnSend, OnReceive, OnComplete, SendRecv_Act_GOTO_SEND, 5000, 5000, 1024);
}

public SendRecv_Act:OnSend(Handle:hndl, CURLcode: code, const last_sent_dataSize)
{
    PrintToServer("OnSend called");
    
    if(hndl != INVALID_HANDLE && code != CURLE_OK)
    {
        new String:error_buffer[256];
        curl_easy_strerror(code, error_buffer, sizeof(error_buffer));
        PrintTestCaseDebug(5, "FAIL - %s", error_buffer);
        CloseHandle(hndl);
        return SendRecv_Act_GOTO_END;
    }
    
    return SendRecv_Act_GOTO_RECV;
}

public OnComplete(Handle:hndl, CURLcode: code , any:data)
{

}

public SendRecv_Act:OnReceive(Handle:hndl, CURLcode: code, const String:receiveData[], const dataSize)
{
    PrintToServer("OnReceive called");

    //new current_test = data;
    if(hndl != INVALID_HANDLE && code != CURLE_OK)
    {
        new String:error_buffer[256];
        curl_easy_strerror(code, error_buffer, sizeof(error_buffer));
        PrintTestCaseDebug(5, "FAIL - %s", error_buffer);
        CloseHandle(hndl);
        return SendRecv_Act_GOTO_END;
    }
    
    //PrintToChatAll("curl_recive: %s %s", data, current_test);
    PrintToServer("curl_recive: %s", receiveData);
    
    return SendRecv_Act_GOTO_END;
}
But every time i get:
Quote:
OnSend called
[CURL Test #5] FAIL - Failed sending data to the peer
Can someone help please? I have no more ideas...
ftopku is offline
Mister_Magotchi
SourceMod Donor
Join Date: Dec 2006
Location: Nampa, Idaho
Old 11-09-2013 , 02:46   Re: [EXTENSION] cURL & Hash
Reply With Quote #85

I don't believe it's the cause of your error, but I believe you need to work with that "CURLOPT_WRITEFUNCTION" callback if you want to write your data directly to a string rather than to a file.
Mister_Magotchi is offline
mukunda
Member
Join Date: Sep 2012
Old 11-11-2013 , 19:35   Re: [EXTENSION] cURL & Hash
Reply With Quote #86

Register a library for this please!
__________________
mukunda is offline
puga4off
Junior Member
Join Date: Nov 2013
Old 11-15-2013 , 01:49   Re: [EXTENSION] cURL & Hash
Reply With Quote #87

Hello everybody. Sorry, my English is bad. I have some problem with curl, more exactly with function curl_easy_perform_thread. I wanna to execute 1000 curl requestes. How i did it. At first i wrote my own plugin, but i could do this, because when i am creating more that ~400-500 curles and they doesn't want to execute. Then i downloaded curl_examples "curl_write_function.sp". and when i tried again to did it, on ~400-500 time it was broken again. Can you explain please, where is my error and how to solve it. Thanks. Sorry again for my English:#

I created curls in Timer
curl_write_function.sp
puga4off is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 11-15-2013 , 08:48   Re: [EXTENSION] cURL & Hash
Reply With Quote #88

What are you trying to do exactly? Also we can't help you without the code you're using.

[edit]

Are you getting any errors or anything?

Last edited by bl4nk; 11-15-2013 at 08:50.
bl4nk is offline
puga4off
Junior Member
Join Date: Nov 2013
Old 11-15-2013 , 10:33   Re: [EXTENSION] cURL & Hash
Reply With Quote #89

i have very interesting result. i wrote this functions to know what is happening with curls.

PHP Code:
MyCurlCreateHandle()
{
    new 
Handle:curl curl_easy_init();
    
PrintToServer("curl address %d"curl);
    return 
curl;
}

MyDeleteCurlHandle(Handle:curl)
{
  
PrintToServer("delete curl address %d"curl);
  
CloseHandle(curl);

And i noticed, that after 500 times creating and using function "curl_easy_perform_thread" sourcemod doesn't want to delete curls handles, only create. and then ofcourse after creating some handles there are memory leak("out of memory"). The question is why sourcemod doesn't want to execute curl by threads. I tested and found if i executed curl without threads , it works. but you understand, that i can't do it Please help

Last edited by puga4off; 11-15-2013 at 10:37.
puga4off is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 11-15-2013 , 17:26   Re: [EXTENSION] cURL & Hash
Reply With Quote #90

I'm still wondering why the webternet extension (which is in the sourcemod source code under extensions/curl) doesn't have a plugin API of its own.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Reply



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 04:26.


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