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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:30:06+00:00 2026-05-26T21:30:06+00:00

I’m using Facebook’s Batch Requests to post to multiple feeds and I need to

  • 0

I’m using Facebook’s Batch Requests to post to multiple feeds and I need to link the correct response to every request in the batch. Since I found no definitive info on the documentation, do the members of the returned array appear in the same order as the requests?

In other words, if I get an error in the third member of the returned array, does that positively mean that the error refers to the third request I sent in the batch?

I can use the id for succesful requests, but error messages seem general and do not bring any data linked to the request that generated them (unless I’m missing something).

  • 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-26T21:30:07+00:00Added an answer on May 26, 2026 at 9:30 pm

    Yes, that’s correct.

    My strategy is that I create a tracking array as I load up my batch requests. This array correlates the key for my associative array to the numerical order I posted the batches. When I loop over the results, I use a counter to step through the tracking array and pull out the proper associative array index. Then I use that to update the associative array with the results from that step of the batch operation.

    It would be nice if batching supported the ‘name’ parameter and that parameter got returned with each response. But that only appears to work if you’re using the name to create batch dependencies:
    https://developers.facebook.com/docs/reference/api/batch/

    Loading up the batches:

    foreach ($campaigns as $title => $campaign) {
        if (count($batch) == 20) {
            $batches[] = $batch;
            $batch = array();
        }
    
        $titles[] = $title;  #TRACKING array;
        $body = http_build_query($campaign);
        $body = urldecode($body);
    
        $batch[] = array(
            'method' => 'POST',
            'relative_url' => "/act_{$act}/adcampaigns",
            'body' => $body
        );
    }
    

    Processing the batches:

    if ($batch) {
        $batches[] = $batch;
        $counter = 0;
    
        foreach ($batches as $batch) {
            $params = array(
              'access_token' => $access_token,
              'batch' => json_encode($batch)
            );
    
            $responses = $facebook->api('/', 'POST', $params);
    
            foreach ($responses as $response) {
                $response = json_decode($response['body'], 1);
                $campaign_id = $response['id'];
                $title = $titles[$counter];  #RETRIEVING THE INDEX FROM THE TRACKING ARRAY
                $campaigns[$title]['campaign_id'] = $campaign_id;
                $counter++; #INCREMENTING THE COUNTER
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I need to clean up various Word 'smart' characters in user input, including but
I need a function that will clean a strings' special characters. I do NOT

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.