基本 php 程序:警告:session_start() [function.session-start]

发布于 2024-12-11 16:24:25 字数 1294 浏览 2 评论 0原文

我是 Facebook 应用程序开发新手。我创建了一个用于学习的示例应用程序。代码如下。基本上我想打印用户的个人资料名称。如果我能得到这段代码的解释,特别是斜体部分的解释,那就太好了。

enter code here
<html> 
<body>
<h1> Inspirations </h1>
<div id = "quote">
<span id="facebook_stuff">
<div id = "profile_pic"><img src="https://graph.facebook.com/1452321522/picture"      border="0" /> </div>
<?php
 require 'facebook.php' ;
 $facebook = new Facebook(array(
 ‘appId’ => 'my app id',
 ‘secret’ => 'my app secret',
 'cookie' => 'true',

   ));

 $user = $facebook->api('/1452321522');

  ?>
      <div id="profile_name"> <?php echo $user['name'] ?> </div>
   </span>
    "Love is god"
   </div>
    </body>
     </html>

我得到以下输出

灵感

{image}

警告:session_start() [function.session-start]: 无法发送会话 cookie - 标头已发送(输出从 /home/content/04/ 开始) 8471304/html/index.php:5) 在 /home/content/04/8471304/html/facebook.php 第 37 行

警告:session_start() [function.session-start]:无法发送会话缓存限制器 - 标头已发送(输出从 /home/content/04/8471304/html/index.php:5 开始)在 /home/content/04/8471304/html/facebook.php 第 37 行

致命错误:未捕获的 OAuthException:无效的 OAuth 访问令牌签名。扔进 /home/content/04/8471304/html/base_facebook.php 第 970 行

I am new to Facebook app development. I created a sample app for learning. the code is as follows . Basically i want to print the profile name of the user. It will be great if I can get explanation of this code especially for the Italicized section.

enter code here
<html> 
<body>
<h1> Inspirations </h1>
<div id = "quote">
<span id="facebook_stuff">
<div id = "profile_pic"><img src="https://graph.facebook.com/1452321522/picture"      border="0" /> </div>
<?php
 require 'facebook.php' ;
 $facebook = new Facebook(array(
 ‘appId’ => 'my app id',
 ‘secret’ => 'my app secret',
 'cookie' => 'true',

   ));

 $user = $facebook->api('/1452321522');

  ?>
      <div id="profile_name"> <?php echo $user['name'] ?> </div>
   </span>
    "Love is god"
   </div>
    </body>
     </html>

I am getting the following output

Inspirations

{image}

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/04/8471304/html/index.php:5) in /home/content/04/8471304/html/facebook.php on line 37

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/04/8471304/html/index.php:5) in /home/content/04/8471304/html/facebook.php on line 37

Fatal error: Uncaught OAuthException: Invalid OAuth access token signature. thrown in /home/content/04/8471304/html/base_facebook.php on line 970

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

玩套路吗 2024-12-18 16:24:25

对于前两个警告,您尝试在输出已经开始后发送标头(cookie 和缓存限制器),尝试将 php 代码移动到顶部:

 <?php
 require 'facebook.php' ;
 $facebook = new Facebook(array(
 ‘appId’ => 'my app id',
 ‘secret’ => 'my app secret',
 'cookie' => 'true',

   ));

 $user = $facebook->api('/1452321522');

  ?>
<html> 
<body>
<h1> Inspirations </h1>
<div id = "quote">
<span id="facebook_stuff">
<div id = "profile_pic"><img src="https://graph.facebook.com/1452321522/picture"      border="0" /> </div>
<div id="profile_name"> <?php echo $user['name'] ?> </div>
</span>
   "Love is god"
</div>
</body>
</html>

我不能说致命错误,尽管我的预感它与前两个警告有关,或者是因为您传递了“appId”和“secret”的虚拟值(这些值没有正确包含在撇号中,本身可能会生成错误)

For the first two warnings, you're trying to send headers (cookies and cache limiter) after output has already started, try moving the php code to the top as so:

 <?php
 require 'facebook.php' ;
 $facebook = new Facebook(array(
 ‘appId’ => 'my app id',
 ‘secret’ => 'my app secret',
 'cookie' => 'true',

   ));

 $user = $facebook->api('/1452321522');

  ?>
<html> 
<body>
<h1> Inspirations </h1>
<div id = "quote">
<span id="facebook_stuff">
<div id = "profile_pic"><img src="https://graph.facebook.com/1452321522/picture"      border="0" /> </div>
<div id="profile_name"> <?php echo $user['name'] ?> </div>
</span>
   "Love is god"
</div>
</body>
</html>

I can't say as far as the fatal error, although my hunch is that it is related to the first two warnings, or it is because you're passing dummy values for 'appId' and 'secret' (which are not encased in apostrophes proper and might generate an error themselves)

非要怀念 2024-12-18 16:24:25

正如 bkconrad 所说,前两个警告是为了,您在将一些信息发送到浏览器之后发送一些标头信息。

为此,您可以按照 bkconrad 的建议尝试或使用 ob_start()ob_end_flush()
对于致命错误,您必须提供您在 facebook 中创建的 ID 和密码。

我假设您已经创建了 facebook 应用程序,因此请登录 facebook 并转到 facebook aps。您在那里列出了您创建的应用程序。将应用 ID/API 密钥应用密钥复制并粘贴到您的代码中。就是这样。

As said by bkconrad,the first two warnings is for, you are sending some header information after some information sent to the browser.

For this you can try as suggested by bkconrad or use ob_start() and ob_end_flush()
functions.And for the fatal error, you must give your id and secret code created in your facebook.

I assume you've created facebook application, so login into facebook and go to facebook aps. There you've listed applications created by you. copy and paste App ID/API Key and App Secret in your code. That's it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文