0

For sending a user a Boxcar notification, I use this example:

curl_setopt_array(
    $chpush = curl_init(),
    array(
        CURLOPT_URL => "https://new.boxcar.io/api/notifications",
        CURLOPT_POSTFIELDS => array(
            "user_credentials" => 'ACCESS_TOKEN',
            "notification[title]" => 'message title',
            "notification[long_message]" => '<b>Some text or HTML for the full layout page notification</b>',
            "notification[sound]" => "bird-1",
        )));
$ret = curl_exec($chpush);
curl_close($chpush);

But I get some output on my page, which is probably the response of the Boxcar server. How can I prevent that output from being printed?

B_s
  • 3,026
  • 5
  • 32
  • 51
  • i don't see anything here that outputs to a page. I assume you are doing something downstream with $ret that does. if that's the case then include that. – hubson bropa Jun 09 '15 at 16:10
  • No, not doing anything with `$ret`, I already found the solution, will post my answer now. – B_s Jun 09 '15 at 16:14

1 Answers1

0

I already found the solution:

Set CURLOPT_RETURNTRANSFER to TRUE. See this StackOverflow Answer for more information. For future reference, to send the user a Boxcar notification, you could also use:

$chpush = curl_init();
$boxcarData = array(
        "user_credentials" => 'ACCESS_TOKEN',
        "notification[title]" => 'message title',
        "notification[long_message]" => '<b>Some text or HTML for the full layout page notification</b>',
        "notification[sound]" => "bird-1",
);
curl_setopt($chpush, CURLOPT_URL, "https://new.boxcar.io/api/notifications");
curl_setopt($chpush, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($chpush, CURLOPT_POSTFIELDS, $boxcarData);
$ret = curl_exec($chpush);
curl_close($chpush);
Community
  • 1
  • 1
B_s
  • 3,026
  • 5
  • 32
  • 51