FB API Cookie标头错误

编程入门 行业动态 更新时间:2024-10-17 09:50:49
本文介绍了FB API Cookie标头错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有如下代码:

require '../lib/facebook-php-sdk/src/facebook.php'; $facebook = new Facebook(array( 'appId' => '143944345745133', 'secret' => 'xxxxxxxx', 'cookie' => true, )); $user = $facebook->getUser(); if ($user) { try { $user_profile = $facebook->api('/me'); } catch (FacebookApiException $e) { $user = 0; } } if ($user) { setcookie('loggedUserId', $user, time()+36000); setcookie('loggedUserName', $user_profile['name'], time()+36000); } else { setcookie('loggedUserId', '', time()-3600); setcookie('loggedUserName', '', time()-3600); }

我在我的php错误日志文件中得到错误:

and I get the error in my php error log file:

[17-Dec-2012 06:11:34 UTC] There exists a cookie that we wanted to clear that we couldn't clear because headers was already sent. Make sure to do the first API call before outputing anything.

请帮助我修复它。结果用户体验是,我登录后,页面需要重新加载到实际登录。感谢

Please help me fix it. The result user experience is that after I log in, the page needs to be reloaded to actually log in. Thanks

推荐答案

p>代码中的东西在调用setcookie之前会输出一些东西。它可以是调试消息。或者甚至在打开<?php标记之前的空行。

Something in your code is outputting something before the call to setcookie. It could be a debug message. Or even an empty line before opening <?php tag.

更多推荐

FB API Cookie标头错误

本文发布于:2023-11-14 19:58:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1588378.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   FB   API   Cookie

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!