Send icq message via php - php

I need to send message to icq from php. I`m using WebIcqPro.
<?php
require_once('WebIcqPro.class.php');
$uin = '******';
$pass = '******';
$to_uin = '******';
$icq = new WebIcqPro();
$icq->debug = true;
$icq->setOption('UserAgent', 'miranda');
if ($icq->connect($uin, $pass)) {
$icq->sendMessage($to_uin, 'Hello! This is a test message');
} else {
die('ICQ connection error: ' . $icq->error);
}
This code fails with error: Error: Server close connection
P.S.: Maybe there are other working icq classes?

increase the limits.
edit file "WebIcqPro.class.php":
// $this->setTimeout(6, 0);
$this->setTimeout(60, 60000);

Related

NuSOAP PHP web service and sending large string

again i am seeking for you help! I am new to NuSOAP, so please bear with me. I am trying to send multiple records, with multiple columns to my service, split this into records and writting them into my sql table.
For example, i have a batch that updates my variable like so (records are separated with ";", columns inside records are separated with "¤")
Name1¤Surname1¤Date1¤number1;Name2¤Surname2¤Date2¤number2;Name3¤Surname3¤Date3¤number3 ...
I have a simple function which accepts this variable. (1st of all i dont know if sending a string is optimal ... I read that i should be sending an xml document ...)
So if i declare a new variable inside my script and past the exact value that my program sets up, execute the script, everything works! Records are written in a table without any problem. I wrote up to 500 records. The problem is when i call my webservice ... In that case i get an error:
"SOAP Fault: error in msg parsing: XML error parsing SOAP payload on line 1: Invalid character:"
I think i am sending a to many chars in my variable ... Again i am new to NuSOAP and i am trying to figure this out based on an example i found online ...
When i was sending just text with only 1 delimeter, i was able to sent and write 500 records. The variable was setup like so:
TEST001;TEST002;TEST003; ...;TEST500
And the web service recieved the variable and wrote all 500 records to the table. Can someone please help me out or tell me the correct way of doing this?
Regards,
HEki
<?php
require 'lib/nusoap.php';
$server = new nusoap_server();
$server->configureWSDL("test"."urn:test");
$server->register(
"service",
array("variable_text"=>'xsd:string'),
array("return"=>"xsd:string")
);
function service($variable_text)
{
$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password = "root";
$mysql_database = "service";
$today = date("Y-m-d");
$response='START';
// Connect to database server
$con = mysqli_connect($mysql_hostname, $mysql_user, $mysql_password, $mysql_database);
if (mysqli_connect_errno()) {
echo "ERROR: " . mysqli_connect_error();
}
$token = strtok($variable_text, ";");
while ($token !== false)
{
$data = explode('¤', $token);
$data0 = $data[0];
$data1 = $data[1];
$data2 = $data[2];
$data3 = (int)$data[3];
$strSQL = "INSERT INTO test (column1,column2,column3,column4) VALUES ('".$data0."','".$data1."','".$data2."', '".$data3."')";
mysqli_query($con,$strSQL);
$response='NEW';
$token = strtok(";");
}
// Close the database connection
mysqli_close($con);
return $response;
}
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>

phpMQTT non-blocking publish & recieve

I am writing a program connecting a web service in PHP to an MQTT broker. The broker is running Mosquitto on a Raspberry Pi.
The idea is to have the web service send a request (a form is submitted) and then send a publish to the MQTT broker and then wait for a reply.
However, the problem is that the loop seems to cause a PHP fatal error due to the fact that it is an endless loop.
I've tried adding the quitstop() function to quit the loop after a message is received, but the program crashes before it reaches that point.
MQTT is still very new to me, but I need to send the request and then keep the loop open until I receive the answer in order to proceed with my program.
This is the code to handle the form submit:
require("phpMQTT.php");
$server = "xxx.xxx.xxx.xx"; // change if necessary
$port = 1883; // change if necessary
$username = "username"; // set your username
$password = "password"; // set your password
$client_id = "phpMQTT-request-1234"; // make sure this is unique for connecting to sever - you could use uniqid()
$mqtt = new phpMQTT($server, $port, $client_id);
$msg = $_POST['box'];
if (!empty($msg)) {
if ($mqtt->connect(true, null, $username, $password)) {
$mqtt->publish("dev/test", $msg, 0);
$mqtt->close();
}
subscribeToTopic($mqtt);
}
function subscribeToTopic($mqtt)
{
$topics['dev/test'] = array("qos" => 0, "function" => "procmsg");
$mqtt->subscribe($topics, 0);
while ($mqtt->proc()) {
}
$mqtt->close();
}
function procmsg($topic, $msg)
{
global $mqtt;
echo $msg;
quitstop($mqtt);
}
function quitstop($mqtt)
{
$mqtt->close();
}

Can't access to Office365 accout with IMAP & PHP

I am trying to access to office365 inbox, but I am getting this message
PHP Warning: imap_open(): Couldn't open stream {outlook.office365.com:993/imap/ssl}
Here is my code
$hostname = '{outlook.office365.com:993/imap/ssl/novalidate-cert}';
$username = '*****';
$password = '*****';
$fp = fopen('cox_cash [30 40].txt', 'w+');
if (!$fp) die("Impossible d'ouvrir le fichier");
/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to : ' . imap_last_error());
For me, the issue was not having the imap library for php. Try using function_exists('imap_open') to check if you actually have the library. function_exists() returns true if your php has the function, false otherwise. Simple if statement with echos should do the trick.

Is any other way to read message from webmail on cpanel using PHP with out using IMAP function

I'm integrating PHP webmail read functionality in php. I already tried using IMAP functions. But it could not connect.So I just ask you is there any possibility to get messages from webamil with out using IMAP function.
Below is my IMAP Code. Can you check the code also give me suggestions for why doesn't work. I'm looking forward for your valuable reply.
$emailAddress = 'info#example.com'; // Full email address
$emailPassword = 'xxxxxxxx'; // Email password
$domainURL = 'example.com'; // Your websites domain
$useHTTPS = false;
/* BEGIN MESSAGE COUNT CODE */
$inbox = imap_open('{'.$domainURL.':143/notls}INBOX',$emailAddress,$emailPassword) or die('Cannot connect to domain:' . imap_last_error());
$oResult = imap_search($inbox, 'UNSEEN');
if(empty($oResult))
$nMsgCount = 0;
else
$nMsgCount = count($oResult);
imap_close($inbox);
echo('<p>You have '.$nMsgCount.' unread messages.</p>');
Thanks in advance

Creating messages (ie drafts) in Gmail with IMAP/SMTP?

I've done quite a bit of inbox manipulation with Gmail via IMAP functions in PHP, but one thing I haven't found is a way to create messages. I'm not sure if IMAP or SMTP is required, but I would like to use PHP to create a new message (specifically a draft) that is stored in my inbox with everything ready to hit send at a later date. How do I go about this?
You might want to look at imap_mail_compose()
Edit
This doesn't create the message on the server. You need to use imap_append() also.
Further Edit
This seems to work ok:
<?php
$rootMailBox = "{imap.gmail.com:993/imap/ssl}";
$draftsMailBox = $rootMailBox . '[Google Mail]/Drafts';
$conn = imap_open ($rootMailBox, "sdfsfd#gmail.com", "password") or die("can't connect: " . imap_last_error());
$envelope["to"] = "test#test.com";
$envelope["subject"] = "Test Draft";
$part["type"] = TYPETEXT;
$part["subtype"] = "plain";
$part["description"] = "part description";
$part["contents.data"] = "Testing Content";
$body[1] = $part;
$msg = imap_mail_compose($envelope, $body);
if (imap_append($conn, $draftsMailBox, $msg) === false) {
die( "could not append message: " . imap_last_error() ) ;
}

Categories