2013-02-19 96 views
0

我有下面卷曲代码PHP的:卷曲不需要输出

<?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); 
?> 

在上面的代码中,我没有使用echo $结果,但其作为{"id":"209557021119579"}

回答

0

使用该返回输出:

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

用于返回数据而不是回显数据

+0

感谢工作,, – 2013-02-19 07:28:36

0

您应该使用CURLOPT_RETURNTRANSFER,

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);