Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 静音输出旋度设置选择数组_Php_Curl - Fatal编程技术网

Php 静音输出旋度设置选择数组

Php 静音输出旋度设置选择数组,php,curl,Php,Curl,为了向用户发送Boxcar通知,我使用以下示例: curl_setopt_array( $chpush = curl_init(), array( CURLOPT_URL => "https://new.boxcar.io/api/notifications", CURLOPT_POSTFIELDS => array( "user_credentials" => 'ACCESS_TOKEN',

为了向用户发送Boxcar通知,我使用以下示例:

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);
curl\u setopt\u数组(
$chpush=curl\u init(),
排列(
CURLOPT_URL=>”https://new.boxcar.io/api/notifications",
CURLOPT_POSTFIELDS=>数组(
“用户凭据”=>“访问令牌”,
“通知[标题]”=>“消息标题”,
“通知[长消息]”=>“用于完整布局页面通知的某些文本或HTML”,
“通知[声音]”=>“鸟-1”,
)));
$ret=curl\u exec($chpush);
卷曲关闭($chpush);

但是我在页面上得到了一些输出,这可能是Boxcar服务器的响应。如何防止打印输出?

我已经找到了解决方案:

CURLOPT\u RETURNTRANSFER
设置为
TRUE
。有关更多信息,请参阅StackOverflow答案。为了便于将来参考,要向用户发送Boxcar通知,您还可以使用:

$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);
$chpush=curl_init();
$boxcarData=数组(
“用户凭据”=>“访问令牌”,
“通知[标题]”=>“消息标题”,
“通知[长消息]”=>“用于完整布局页面通知的某些文本或HTML”,
“通知[声音]”=>“鸟-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\u exec($chpush);
卷曲关闭($chpush);

我在这里没有看到任何输出到页面的内容。我假设您正在使用$ret进行下游操作。如果是这样的话,那么就把它包括进去。不,不使用
$ret
做任何事情,我已经找到了解决方案,现在就发布我的答案。