Closed mgp25 closed 11 years ago
Uncomment line 38 to 42 in index.php and check the output you get after a while https://github.com/venomous0x/WhatsAPI/blob/master/src/php/ajaxDemo/index.php#L38
@shirioko ty!, now its returning this error. Related with:
session_start();
<b>Warning</b>: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent by (output started at /whatsprot.class.php:1404) in <b>ajaxDemo/socket.php</b> on line <b>37</b><br /> <br />
<b>Warning</b>: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at whatsprot.class.php:1404) in <b>ajaxDemo/socket.php</b> on line <b>37</b><br />
Add
ob_start();
at the beginning and
ob_flush();
at the end of socket.php
Hmm, just realized that socket.php has no PHP closing tag... late night coding struggles :/
No errors now, although incoming messages are not being displayed yet.
with
$debug = true;
rx <message from="34***@s.whatsapp.net" id="message-1381618532-1" type="chat" t="1381618532"> rx <notify xmlns="urn:xmpp:whatsapp" name="Test :D"></notify> rx <request xmlns="urn:xmpp:receipts"></request> rx <body>hola</body> rx </message>
Not displayed but received.
Something messed up your PHP sessions. Do you have cookies enabled? What is your server setup?
Yup, i have cookies enabled.
PHP version => PHP Version 5.3.27
session.use_cookies On On
session.use_only_cookies On On
oh ffs I see the problem Let me push a fix
@mgp25 can you confirm this fix? :)
@shirioko :D
Fully working! Profile picture is not displayed but i think i can figure it out.
Thx ;)
Fixed profile picture as well.
@shirioko i tried the latest fix, profile picture is not displayed. We may have overlooked something.
Do you have the ../pictures folder and write permissions for it?
Yup. 777
$filename = "../".WhatsProt::PICTURES_FOLDER."/" . $filename;
I have another script and its working. I dont know what could be happening with ajaxDemo :/
function onGetProfilePicture($from, $target, $type, $data)
{
if ($type == "preview") {
$filename = "preview_" . $target . ".jpg";
} else {
$filename = $target . ".jpg";
}
$filename = WhatsProt::PICTURES_FOLDER."/" . $filename;
$fp = @fopen($filename, "w");
if ($fp) {
fwrite($fp, $data);
fclose($fp);
}
echo '<a href="'.$filename.'"><center><img src="'.$filename.'" height="250" width="250"></center></a><br><br>';
}
$w->eventManager()->bind("onGetProfilePicture", "onGetProfilePicture");
$w->sendGetProfilePicture($target, true);
@shirioko did you found what happened? Also there is a vuln using ajaxDemo… PoC on image:
This is easily fixed, so we dont have to be worried at all :p
Profile picture works for me though. What's the debug output you get in your script? Change lines 38-42 to
if(data)
{
var foo = $("#debug").html();
$("#debug").html(foo + data);
}
to fix formatting
@shirioko omg… my fault, never mind. Its working 100%
@shirioko just one more thing.
$w->SendPresenceSubscription($target);
It suppossed to print if target is online, offline or either typing right? because it doesnt, i need to code something?
<span id="contactname"></span>
<br />
<span id="contactstatus"></span>
If i want for example to print last seen time using ajax:
socket.php
function onGetRequestLastSeen($username, $msgid, $seconds)
{
// function
// ...
session_start();
$_SESSION["lastseen"] = $lastseen;
session_write_close();
}
$w->eventManager()->bind('onGetRequestLastSeen', 'onGetRequestLastSeen');
$w->sendGetRequestLastSeen($target);
on index.php should i only do this?
<span id="contactstatus"></span>
I know... i have to get in touch with this languages
Hi, im trying ajaxDemo, and it sends perfectly messages to the target, but i cant figure out why the incoming messages are not being displayed. The target's profile picture too.
Any idea?