October 26, 2024
Chicago 12, Melborne City, USA
PHP

Error when trying to Send SMS via WP_REMOTE POST


i’m facing a little problem here. I have these codes saved in send-sms.php file trying to setup an SMS API using wp_remote_post with my site. As part of my trial every time i run my codes below i get response that i don’t understand.

These are the codes

<?php

require_once 'wp-load.php';


$url="https://api.sprintsmsservice.com/api/SendSMS";

$response = wp_remote_post( $url, array(
'method'      => 'POST',
'timeout'     => 45,
'redirection' => 5,
'httpversion' => '1.0',
'blocking'    => true,
'headers'     => array(),
'body'        => array(
'api_id'=>'xxxxxx',
'api_password'=>'xxxxxx',
'sms_type'=>'T',
'encoding'=>'T',
'sender_id'=>'ChonryOTP',
'phonenumber'=>255714812XXX,
'templateid'=>null,
'textmessage'=>'Hello, This is a test message',

),
'cookies'     => array()
    )
);

if ( is_wp_error( $response ) ) {
$error_message = $response->get_error_message();
echo "Something went wrong: $error_message";
} else {
echo 'Response:<pre>';
print_r( $response );
echo '</pre>';
}


?>

And these are the results when i run the send-sms.php file (You can view full results in this LINK)

                    [status_code] => 415
                    [protocol_version] => 1.1
                    [success] => 
                    [redirects] => 0
                    [url] => https://api.sprintsmsservice.com/api/SendSMS/
                    [history] => Array
                        (
                        )

                    [cookies] => WpOrg\Requests\Cookie\Jar Object
                        (
                            [cookies:protected] => Array
                                (
                                )

                        )

                )

            [filename:protected] => 
        )

)

Where i’m doing wrong? Because if i reload this file no SMS is sent to my number



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video