将数据发布到Curl有问题 - 卷曲没有回复

I am trying to implement spam checks for websites, Like I have website A,B,C,D... I am creating a centralized spam check filter say xyz.com/spamcheck.php

I am using CURL to post the data from website A to xyz.com/spamcheck.php and in my spamcheck.php I am using Akismet Fuspam library to validate it and return the response back to my website A, based on the response from my spamcheck i will decide to send mail or discard.

So far i am not able to post values to my spamcheck.php through CURL and get response back from it.


    // DATA PROCESSING
    $data = array();

    $data['ip']                     = get_client_ip();
    $data['user_agent']             = $_SERVER['HTTP_USER_AGENT'];
    $data['referrer']               = $_SERVER['HTTP_REFERER'];
    $data['comment_author']         = $_POST['first_name'];
    $data['comment_author_email']   = $_POST['email'];
    $data['comment_content']        = $_POST['message'];

    $params = json_encode($data);

    $url                            = "https://www.my-spam-check-url.com/spamcheck.php";

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $params);

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // On dev server only!

    $spamResult = curl_exec($ch);

    curl_close($ch);

     $spamResult = json_decode($spamResult,true);
     print_r($spamResult);

I expect the output to be TRUE or FALSE. I am getting Blank response

spamcheck.php

// Include Akismet F-U-Spam function.
include 'includes/akismet.fuspam.php';

// Function to get the client IP address
function get_client_ip() {
    $ipaddress = '';
    if (isset($_SERVER['HTTP_CLIENT_IP']))
        $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
    else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
        $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
    else if(isset($_SERVER['HTTP_X_FORWARDED']))
        $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
    else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
        $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
    else if(isset($_SERVER['HTTP_FORWARDED']))
        $ipaddress = $_SERVER['HTTP_FORWARDED'];
    else if(isset($_SERVER['REMOTE_ADDR']))
        $ipaddress = $_SERVER['REMOTE_ADDR'];
    else
        $ipaddress = 'UNKNOWN';
    return $ipaddress;
}

/*API KEY - 123XYZ*/

$comment    = array();
$key        = "123XYZ";
$type       = "check-spam";

/*  Get Posted Data from website */
$postedIp                       = $data['ip'];
$postedUserAgent                = $data['user_agent'];
$postedReferrer                 = $data['referrer'];
$postedcomment_author           = $data['comment_author'];
$postedcomment_author_email     = $data['comment_author_email'];
$postedcomment_content          = $data['comment_content'] ;

/* Data Processing End */
if(empty($postedIp) || $postedIp == 'UNKNOWN' || $postedIp == ''){
    $ip = get_client_ip();
}


if(empty($postedUserAgent) || $postedUserAgent == ''){
    $user_agent = $_SERVER['HTTP_USER_AGENT'];
}


if(empty($postedReferrer) || $postedReferrer == ''){
    $referrer   = $_SERVER['HTTP_REFERER'];
}


$permalink = $blog = $authUrl = "https://www.example.net/";

$comment['blog']                    = $blog;
$comment['user_ip']                 = $ip;
$comment['user_agent']              = $user_agent;
$comment['referrer']                = $referrer;
$comment['permalink']               = $permalink;
$comment['comment_type']            = "ContactUs";
$comment['comment_author']          = $postedcomment_author;
$comment['comment_author_email']    = $postedcomment_author_email;
$comment['comment_author_url']      = $authUrl;
$comment['comment_content']         = $postedcomment_content;


$spamCheckResult = fuspam( $comment , $type , $key );


echo $spamCheckResult;

I am looking at your code, I cant be sure if print_r is how you are checking but if so, keep in mind that:

print_r(true) will output 1, while print_r(false) will output "", blank.

Maybe use var_dump instead for debugging?

BR

If your spamcheck.php is working as per your written code than before echo in last use ob_clean();. so i will remove space or any other before return your actual result.