@bladbirne
Здравствуйте, я использую клас Yapi для перевода средств другим пользователям юмани через апи, но у меня почему-то не отправляется средства, помогите, пожалуйста, очень нужна помощь. В токене есть разрешение для переводов.
Вот код:
Вот код:
class YApi {
private $_token;
private $_url;
function __construct($token) {
$this->_token = $token;
$this->_url="https://yoomoney.ru/";
}
//array('records'=>'3', 'type'=>'deposition', 'details'=>'true')
private function sendRequest($method, array $content = []) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->_url . $method);
curl_setopt($ch, CURLOPT_POST, 1);
//curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($content));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($content));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Host: yoomoney.ru',
'Content-Type: application/x-www-form-urlencoded',
'Authorization: Bearer ' . $this->_token
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
return json_decode($result, 1);
}
public function getPaymentsHistory(Array $params = []) {
return $this->sendRequest('/api/operation-history', $params);
}
public function SendmoneyYoomoney(Array $params = []) {
return $this->sendRequest('/api/request-payment', $params);
}
}
#Инициализируем класс юмани
$ym = new YApi($Y_token_balance);
#Отправляем деньги
$sendMoney = $ym->SendmoneyYoomoney([
"pattern_id" => 'p2p',
"to" => '4100116819714112',
"amount" => 5,
"comment" => 'hello',
"message" => 'test'
]);
Решения вопроса 0
Ответы на вопрос 0