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 7014061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:28:18+00:00 2026-05-27T22:28:18+00:00

Function function curlPost($url, $postArray = NULL, $timeout=2, $errorReport=FALSE) { # PREPARE THE POST STRING

  • 0

Function

function curlPost($url, $postArray = NULL, $timeout=2, $errorReport=FALSE) {
    # PREPARE THE POST STRING
    if ($postArray != NULL) {
        $postString = '';
        foreach ($postArray as $key => $val) {
            $postString .= urlencode($key) . '=' . urlencode($val) . '&';
        }
        $postString = rtrim($postString, '&');
    }

    # PREPARE THE CURL CALL
    $curl = curl_init();
    curl_setopt( $curl, CURLOPT_URL,            $url         );
    curl_setopt( $curl, CURLOPT_HEADER,         FALSE        );
    curl_setopt( $curl, CURLOPT_POST,           TRUE         );
    ($postArray != NULL) ? curl_setopt( $curl, CURLOPT_POSTFIELDS,     $postString ) : '';
    curl_setopt( $curl, CURLOPT_TIMEOUT,        $timeout     );
    curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE         );

    # EXECUTE THE CURL CALL
    $htm = curl_exec($curl);
    $err = curl_errno($curl);
    $inf = curl_getinfo($curl);

    # ON FAILURE
    if (!$htm) {
        # PROCESS ERRORS HERE
        if ($errorReport) {
            echo "CURL FAIL: {$url} TIMEOUT={$timeout}, CURL_ERRNO={$err}";
            echo "<pre>\n";
            var_dump($inf);
            echo "</pre>\n";
            createLog("CURL FAIL: {$url} TIMEOUT={$timeout}, CURL_ERRNO={$err}");
        }
        curl_close($curl);
        return FALSE;
    }

    # ON SUCCESS
    curl_close($curl);
    return $htm;
 }

Problem

I’m using cURL in order to execute some bots. For example;

$url = 'http://siteurl.com/crons/transfer_members.php';
$response = curlPost($url, NULL, 10);
echo ($response) ? "{$url} executed" : "Couldn't execute {$url}";

It is working as expected but I have tons of members so I had to use pagination such as;

http://siteurl.com/crons/transfer_members.php?page=1

http://siteurl.com/crons/transfer_members.php?page=2 etc..

It is just transferring first result set and it is not going for other pages. If I execute it manually it is redirecting to next page (if there are records).

What should I do at this point? I’m quite stuck and I am out of ideas at the moment. I will be glad if anyone could help me out with this problem.

Note:

Everything is in the same domain. No tracing any referrer, not checking any cookie. Just pure PHP pages are called. If there is any pagination in the page which was called by cURL I use meta redirects to redirect to next page.

I don’t want to use cURL inside of a loop. If called php page needs pagination I add following code inside of called php page;

# REDIRECT
echo '<meta http-equiv="refresh" content="' . $timer . ';url=' . $url . '">';

EXTRA INFORMATION

I have crons table in my database and I define $url with looping crons table’s records. Some php pages might have pagination, some don’t have any pagination. That’s why I really would like to avoid using cURL calls inside of the loop to paginate.

If pagination is needed, there is pagination in called PHP page. If I visit the called page on browser than it is redirecting me to the next page. I expected the same thing when I call the page with cURL.

Meaning;
if I visit http://siteurl.com/crons/transfer_members.php on my browser it is redirecting me to next page with meta redirect (example : http://siteurl.com/crons/transfer_members.php?page=x)

I expected the same thing with cURL. When cURL would call http://siteurl.com/crons/transfer_members.php it should go through next pages till all pages are finished. It is just visiting the first page and stopping there.

  • 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-05-27T22:28:19+00:00Added an answer on May 27, 2026 at 10:28 pm

    I just had a different approach.
    I returned http://siteurl.com/cron/transfer_members.php?page=n. If returned result starts with http:// or https:// then I called cURLonce again till returned data is finished.

    I still didn’t use cURL in the loop (it would cause other unwanted results) but still managed to make it work.

    Special thanks to @Shiplu.

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

Sidebar

Related Questions

function register_contact ($person = array()) { $nogood = false; foreach ($person as $val) {
<?php function curl_post($url, array $post = NULL, array $options = array()) { $defaults =
Function FillAdminAccount() As Boolean FillAdminAccount = True Try SQLconn.ConnectionString = connect timeout=9999999; & _
function check(id){ var _id = document.getElementById(id); url = test.php?check=1&id= + _id; } i want
function strip_cdata($string) { preg_match_all('/<!\[cdata\[(.*?)\]\]>/is', $string, $matches); return str_replace($matches[0], $matches[1], $string); } I use the
function dowork() { $(.wrappedElement).removeClass(wrappedElement); $(.wrappedElementout).removeClass(wrappedElementout); var a=$(div#DepPart select option:selected).val(); $(div#TestPart select option[value^=a]).addClass(wrappedElement); $(div#TestPart select
function controllaFoto(target, username) { var _URL = window.URL || window.webkitURL; var img = new
function logsig() { var username = $(#username).val(); var password = $(#password).val(); var dataString =
function _(e) { if (typeof e == 'string') { if (e.charAt(0) == '#') {
function MyFunc: Boolean; begin if eval then Result := True else Result := False;

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.