我有以下卷曲代码
<?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 $ result,但是它的返回输出为{"id":"209557021119579"}
答案 0 :(得分:0)
使用此:
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
表示返回数据而不是回显数据
答案 1 :(得分:0)
你应该使用CURLOPT_RETURNTRANSFER,
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);