0

today I wanted to create a very simple php application to chat to facebook friends, but got strucked, I am using xmpphp for connecting to facebook chat. Below is the code I wrote.

<?php
require_once("libs/facebook/src/facebook.php");
require_once("informations/facebook_info.php");
$facebook=new Facebook($config_facebook);
if($facebook->getUser())
{
   //now connect to facebook chat api
   require_once('libs/xmpphp/xmpphp/xmpp.php');
   $accesstoken=$facebook->getAccessToken();
   $con=new XMPPHP_XMPP('chat.facebook.com',5222,'my-id@facebook.com',$accesstoken,'xmpphp','chat.facebook.com');
   $con->useEncryption=false;
   $con->connect();
}
else
{
    header("location:index.php");
}
?>

But it is throwing me a warning saying:

Warning: fclose() expects parameter 1 to be resource, null given in C:\wamp\www\libs\xmpphp\xmpphp\XMLStream.php on line 405

Have I missed something?

Sahil Mittal
  • 20,697
  • 12
  • 65
  • 90
Nicholas Wild
  • 629
  • 1
  • 6
  • 17

1 Answers1

0

Don't pass NULL params to fclose(). Send the handle as a parameter to it.

Something like this

<?php

$handle = fopen('somefile.txt', 'r');

fclose($handle);

?>
Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126
  • that part of code contains, the following code if ($updated === false) { $this->log->log("Error on stream_select()", XMPPHP_Log::LEVEL_VERBOSE);if ($this->reconnect) { $this->doReconnect(); } else { fclose($this->socket); $this->socket = NULL; return false; } – Nicholas Wild Sep 15 '13 at 18:16
  • You can suppress the warning with `@fclose($this->socket);` if everything fails. But i don't suggest that. Can you post the `fopen()` ? – Shankar Narayana Damodaran Sep 15 '13 at 18:19
  • there is no fopen at all, can you go and see xmpphp class first, its complicated, i dont understand it all... – Nicholas Wild Sep 15 '13 at 18:21