@JamesZ Я знаю, что это сообщение об ошибке, но я прошу совета о том, как изменить код, чтобы я мог прочитать сообщение, хранящееся в $ msg. У вас есть идеи, как этого добиться?

од HTTP.call () ниже возвращает нежелательный тарабарщина. Ниже приведен код HTTP.call ():

HTTP.call('POST', 'http://2117c3a8.ngrok.io/AConnect/c2b.php', { 
headers: { apiKey: 'AC6ea8e1541e7ee0c40915e' }, 
data: postData
}, function(error, result) {
if (error) {
    console.log(error);
}
if (result) {
    console.log(result);
}
});

Желаемый возврат должен выглядеть примерно так:

The payment of KES 222 has been sent your account

Но вместо этого я получаю этот бред в терминале:

I20170712-21:18:51.366(3)? { statusCode: 200,
I20170712-21:18:51.368(3)?   content: '<br />\n<b>Notice</b>:     Undefined index: recipient in    <b>/opt/lampp/htdocs/AfricasTalking/escrow/c2b.php</b> on line <b>19</b>   <br />\n<br />\n<b>Notice</b>:  Undefined index: amount in    <b>/opt/lampp/htdocs/AfricasTalking/escrow/c2b.php</b> on line <b>21</b>   <br />\n<br />\n<b>Notice</b>:  Undefined index: payer in    <b>/opt/lampp/htdocs/AfricasTalking/escrow/c2b.php</b> on line <b>26</b>   <br />\n<br />\n<b>Notice</b>:  Undefined index: amount in    <b>/opt/lampp/htdocs/AfricasTalking/escrow/c2b.php</b> on line <b>28</b>   <br />\nReceived error response: The request content was    malformed:\nExpected String as JsString, but got null',
I20170712-21:18:51.368(3)?   headers: 
I20170712-21:18:51.369(3)?    { date: 'Wed, 12 Jul 2017 18:18:49 GMT',
I20170712-21:18:51.370(3)?      server: 'Apache/2.4.18 (Unix)   OpenSSL/1.0.2g PHP/5.6.20 mod_perl/2.0.8-dev Perl/v5.16.3',
I20170712-21:18:51.371(3)?      'x-powered-by': 'PHP/5.6.20',
I20170712-21:18:51.371(3)?      'content-length': '619',
I20170712-21:18:51.372(3)?      connection: 'close',
I20170712-21:18:51.373(3)?      'content-type': 'text/html;  charset=UTF-8' },
I20170712-21:18:51.376(3)?   data: null }
I20170712-21:18:51.400(3)? Exception in callback of async function:   ReferenceError: msg is not defined
I20170712-21:18:51.401(3)?     at server/main.js:39:33
I20170712-21:18:51.402(3)?     at runWithEnvironment  (packages/meteor.js:1176:24)

Файл, который вызывает HTTP.call () (http://2117c3a8.ngrok.io/AConnect/c2b.php) выглядит так

<?php
require_once "AConnect.php";

//Specify your credentials
$username = "007";
$apiKey   = "AC6ea8e1541e7ee0c40915e";        
// NOTE: If connecting to the sandbox, please use your sandbox login credentials

//Create an instance of our awesome gateway class and pass your credentials
$gateway = new AConnect($username, $apiKey, "sandbox");

// Specify the name of your AConnect payment product
$productName  = "cente";
// The 3-Letter ISO currency code for the checkout amount

// Provide the details of a mobile money recipient
$recipient   = array(
"phoneNumber" => $_POST['recipient'],
"currencyCode" => "KES",
"amount" => $_POST['amount'],
"metadata" => array(
"name" => "Something...", 
"reason" => "Som other thing...")
);
$phoneNumber = $_POST['payer'];
$currencyCode = "KES";
$amount = $_POST['amount'];
$metadata = array("name" => "Something...", "reason" => "Som other thing...");


try {
$transactionId = $gateway->initiateMobilePaymentCheckout($productName,
                           $phoneNumber,
                           $currencyCode,
                           $amount,
                           $metadata);
$msg = 'The payment of '. $currencyCode .' '. $amount .' has been sent your account';
$gateway->sendMessage($_POST['recipient'].','.$_POST['payer'], $msg);
echo $msg;
} catch(AConnect $e){
echo "Received error response: ".$e->getMessage();
}
?>

Ниже приводится мой сервер / main.js:

Meteor.methods({
'c2b': function(recipientsNumber, recipientsAmount, payer){

var postData = {
params: {

  "payer": payer,
  "recipient": recipientsNumber,
  "amount": recipientsAmount     
   }
 }

HTTP.call('POST', 'http://2117c3a8.ngrok.io/AConnect/c2b.php', 
{ headers: { apiKey: 'AC6ea8e1541e7ee0c40915e' }, params: postData}, 

  function(error, response) {
    if (error) {
        console.log(error);
    }
    if (response) {

        console.log(response);
    }
  } 
);

 }  
});

Пожалуйста, помогите мне объяснить, как я могу изменить HTTP.call (), чтобы он возвращал соответствующую информацию.

Ответы на вопрос(0)

Ваш ответ на вопрос