doubao6936 2010-08-08 18:19
浏览 112
已采纳

cURL和PHP:停止输出到屏幕

This PHP script prints all the data minus the XML to the browser (I'm using Chrome). How can I suppress output to screen?

<html>
<head><title>Twitcap</title></head>
<body>
<?php
  function twitcap()
  {
    // Set your username and password
    $user = 'osoleve';
    $pass = '********';

    $ch = curl_init("https://twitter.com/statuses/friends_timeline.xml");

    curl_setopt($ch,CURLOPT_HEADER,0); // We want to see the header
    curl_setopt($ch,CURLOPT_TIMEOUT,30); // Set timeout to 30s
    curl_setopt($ch,CURLOPT_USERPWD,$user.':'.$pass); // Set uname/pass
    curl_setopt($ch,CURLOPT_RETURNTRANSER,1); // Do not send to screen

    curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,1);
    curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,1);

    $xml = new SimpleXMLElement( curl_exec($ch) );
    curl_close($ch);

    return $xml;
  }

  $content = twitcap();
  echo "Hello, world.<br /><br />";
?>
</body>
</html>
  • 写回答

1条回答 默认 最新

  • dragon7713 2010-08-08 18:23
    关注

    You ommitted the F in TRANSFER, change this:

    curl_setopt($ch,CURLOPT_RETURNTRANSER,1);

    To this: CURLOPT_RETURNTRANS F ER

    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序