Конвертировать curl в curl php

Мне нужно отправить запрос используя curl php, пример здесь:

curl --header "Content-Type: application/x-www-form-urlencoded" \
        --request POST \
        --data "token=853d6ef12ca044&lang=en&text=Lorem Ipsum" \
        https://api.google.co

Я пытаюсь конвертировать этот код в PHP, но он не работает

$ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://api.google.co');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        "Content-Type"=> "application/x-www-form-urlencoded",
    ));
    $data = array('text' => urlencode("Lorem Ipsum"),
                  'token' => "853d6ef12ca044",
                  'lang' => "en");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    $output = curl_exec($ch);
    curl_close($ch);
    return $output;

В чем может быть проблема? Большое спасибо!


Ответы (0 шт):