Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8778079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:26:19+00:00 2026-06-13T19:26:19+00:00

Plain and simple: I’m generating a list of integers from a database and I

  • 0

Plain and simple: I’m generating a list of integers from a database and I need to upload it to Pastebin.com. Here is my code:

curl_global_init(CURL_GLOBAL_ALL);
if (CURL* curl = curl_easy_init()) {
    std::ostringstream postField;
    postField << "api_user_key=" << "&" << "api_option=paste" << "&" << "api_paste_private=1" << "&";
    postField << "api_paste_name=GuidSet" << "&" << "api_paste_expire_date=10M" << "&";
    postField << "api_paste_format=text" << "&" << "api_dev_key=XXXXXXXXXXXXXXXX" << "&" << "api_paste_code=";
    for (std::set<uint32>::const_iterator itr = resultSet.begin(); itr != resultSet.end(); ++itr) {
        postField << *itr;
        if (itr != --resultSet.end())
            postField << ",";
    }

    struct MemoryStruct chunk;
    chunk.memory = (char*)malloc(1);
    chunk.size   = 1;

    curl_easy_setopt(curl, CURLOPT_URL, "http://pastebin.com/api/api_post.php");
    curl_easy_setopt(curl, CURLOPT_POST, 1);
    char* postStr = curl_easy_escape(curl, postField.str().c_str(), postField.str().length());
    printf("POST parameters: %s\n", postStr);
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postStr);
    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
    curl_easy_setopt(curl, CURLOPT_NOBODY, 0);
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&chunk);
    curl_easy_setopt(curl, CURLOPT_USERAGENT, "TrinityCore GuidBot/1.0");

    curl_easy_perform(curl);
    curl_easy_cleanup(curl);

    self->_parentThread.sendCommand("PRIVMSG %s :%s: Finished, data available at %s",
        searchParams.targetRoom.c_str(), searchParams.actionInvoker.c_str(), chunk.memory);

    if (chunk.memory)
        free(chunk.memory);
    curl_free(postStr);
}
curl_global_cleanup();

However, when executing that code, i always get this:

* About to connect() to pastebin.com port 80 (#0)
*   Trying 72.20.36.113...
* connected
* Connected to pastebin.com (72.20.36.113) port 80 (#0)
> POST /api/api_post.php HTTP/1.1
User-Agent: TrinityCore GuidBot/1.0
Host: pastebin.com
Accept: */*
Content-Length: 609
Content-Type: application/x-www-form-urlencoded

* upload completely sent off: 609 out of 609 bytes
< HTTP/1.1 200 OK
< Server: nginx
< Date: Sun, 28 Oct 2012 11:21:33 GMT
< Content-Type: text/html
< Transfer-Encoding: chunked
< Connection: keep-alive
< Vary: Accept-Encoding
<
* Connection #0 to host pastebin.com left intact
* Closing connection #0
Bad API request, invalid api_option

Is there anything I’m obviously doing wrong ? The chunk that should be pasted has to look like “48,50,59,…etc”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:26:20+00:00Added an answer on June 13, 2026 at 7:26 pm

    Solved it myself, the problem wasnt lying in CURL, but in streaming parameters, although printf’ing stuff didnt show up any space being inserted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to upload a potentially huge plain-text file to a very simple wsgi-app
In my open-source plain C code I use this simple structure to read and
I'm generating plain simple links with CakePHP's HtmlHelper the following way: $html->link(Newest, array( 'controller'
I'd need to create simple patches from git repository that can be applied with
I needed to use XSL to generate simple plain text output from XML. Since
Plain and simple issue: I would like to annotate my method parameter with some
Situation is simple: I post a plain HTML form with a textarea. Then, in
I have a simple three table reference. It looks plain enough. The associations there
I plan on building a simple, yet high usage webapp and need to settle
In plain English this is the jQuery functionality i'm after: I need to get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.