简体   繁体   English

Php:卷曲不必要的输出

[英]Php : Curl unwanted output

I have Below Curl Code 我有以下卷曲代码

<?php
     $url = 'https://graph.facebook.com/me/events';
     $fields = array(
                      'access_token' => $token,
                      'name' => 'Event name',
                      'description' => 'The Description ',
                      'start_time' => '2013-03-02'
                    ); 

     foreach($fields as $key=>$value) 

     {
          $fields_string .= $key.'='.$value.'&';
     }
          rtrim($fields_string, '&');

     $ch = curl_init();
     curl_setopt($ch,CURLOPT_URL, $url);
     curl_setopt($ch,CURLOPT_POST, count($fields));
     curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
     $result = curl_exec($ch);
     curl_close($ch);
?> 

In Above Code , I did not use echo $result , But its returning output as {"id":"209557021119579"} 在上述代码中,我没有使用echo $ result,但是其返回的输出为{"id":"209557021119579"}

Use this : 用这个 :

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

for return data instead of echoing data 用于返回数据而不是回显数据

您应该使用CURLOPT_RETURNTRANSFER,

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM