dongzhu3548 2009-12-11 13:04
浏览 52
已采纳

twitter api在一台服务器上返回xml,在另一台服务器上返回空字符串

I have a php Twitter app which lets you mark tweets as favorite.

I'm doing something like this:

$fav = $twitter->createFavorite("xml", $get_id);//handles api call (using curl)
$fav_result = new SimpleXMLElement($fav);

On my localhost and on one online server all goes well: the tweet is marked as favorite, and the api call returns xml. On another online server, the tweet is also marked as favorite, but php gives an error: Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML'

On the second server, I seem to get an empty string as return value. When I look at the http status codes, when all is well I get a 200, but when things go wrong I get a status code of 0.

When I check the curl_error it says "Failed to open/read local data from file/application"

I think it has to do something with my server configuration. Does anyone have an idea what might be causing this?

  • 写回答

1条回答 默认 最新

  • dongxi5423 2009-12-11 13:57
    关注

    I found the solution here: http://www.milk-hub.net/blog/2008/08/26/curl_error_26 Since no separate postvars are sent, you have to explicitly set the to an empty string:

    curl_setopt($curl_handle, CURLOPT_POSTFIELDS, '');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向