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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:42:50+00:00 2026-06-04T02:42:50+00:00

I need to write a php script, that will do a POST request to

  • 0

I need to write a php script, that will do a POST request to my PhantomJs server, and call some callback function after receiving response.

Let’s say this is my phantomjs server :

var server, service;

server = require('webserver').create();

service = server.listen(8080, function (request, response) {

    //do_something_heavy_with_request_data_here

    response.statusCode = 200;
    response.write("{status: success, data: data}");
    response.close();
});

So from my php script I need to do a request to http://localhost:8080 and when phantomjs finishes it’s calculations and sends response, fire a callback function.
I’ve found this topic : How do I make an asynchronous GET request in PHP? . Anything useful here ? I was thinking about this curl approach, but not sure how to get all of this running together since I’m a total php beginner : How do I make an asynchronous GET request in PHP? .

  • 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-04T02:42:51+00:00Added an answer on June 4, 2026 at 2:42 am

    You can use cURL. http://www.php.net/manual/en/book.curl.php Here’s manual. there’s nothing complicated.

    <?php 
    
    /** 
     * Send a POST requst using cURL 
     * @param string $url to request 
     * @param array $post values to send 
     * @param array $options for cURL 
     * @return string 
     */ 
    function curl_post($url, array $post = NULL, array $options = array()) 
    { 
        $defaults = array( 
            CURLOPT_POST => 1, 
            CURLOPT_HEADER => 0, 
            CURLOPT_URL => $url, 
            CURLOPT_FRESH_CONNECT => 1, 
            CURLOPT_RETURNTRANSFER => 1, 
            CURLOPT_FORBID_REUSE => 1, 
            CURLOPT_TIMEOUT => 4, 
            CURLOPT_POSTFIELDS => http_build_query($post) 
        ); 
    
        $ch = curl_init(); 
        curl_setopt_array($ch, ($options + $defaults)); 
        if( ! $result = curl_exec($ch)) 
        { 
            trigger_error(curl_error($ch)); 
        } 
        curl_close($ch); 
        return $result; 
        } 
    ?>
    

    This is a code from example, that fits your needs.

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

Sidebar

Related Questions

I need to write a PHP script that will print out results from a
I need to write a script in PHP that will display 20 thumbnails at
I want to write a PHP script that will run as a cron job
I am trying to write a PHP script that will create an HTML form
I need to write a php script which is called by a setInterval( ajaxrequest('ftp.php',
I need to write a program in ANSI C that will display the UTF-8
Open Source PHP script for HTTP video streaming? I need some PHP script or
I have a script that will write a given string to a text file...
I need to write a script that takes a link and parses the HTML
I need to write a PHP or javascript that can read the clickbank cookie

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.