I'm having trouble connecting to our Simpro server via the API.
I am using a slightly modified version of the directaccessexample.php as per the Simpro GIT repository here - https://github.com/simPRO-Software/simpro-api-php
My server PHP version is 5.6.32
My composer is loading the below packages:
{
"require": {
"monolog/monolog": "",
"eher/OAuth": "1.0.",
"tivoka/tivoka": "3.1.0",
"psr/log":"*"
}
}
In my attempts to debug, the Client.php script (as provided by the Simpro GIT) appears to fail at specifically the send call from the below lines:
$rpcRequest = new \Tivoka\Client\Request($method, $args);
$this->connection->send($rpcRequest);
I have identified this by outputting to error_log above and below this line - the code appears to die in the function on the send request (and therefore never reaches the second error_log output. There is no error logged that I can see which I find bizarre, it just appears to exit the function.
I am not seeing any other errors in any php error log/apache log/etc, and I've ruled out the issue being the firewall on my server.
I am wondering if this is a problem with versions of PHP or the installed packages from composer - though I have tried a couple of different specific versions without any luck (no change to php version, however).
From the above code, the json_encoded output of $rpcRequest is:
{"id":"7b0911cc-dd67-4032-b810-474e549edecc","method":"CompanySearch","params":["%"],"request":null,"response":null,"result":null,"error":null,"errorMessage":null,"errorData":null,"responseHeaders":null,"responseHeadersRaw":null}
Can anybody assist here? I am pulling my hair out. I'm aware I could attempt to write my own code using different oauth/rpc packages but I am not that advanced with PHP.
Thanks,
Justin.
Related
Hello i have installed Parse server and parse sdk for php on my Linux Centos Server.
Parse Dashboard: 1.3.3,
Server version: 4.3.0
I'm managing those db's using php code. This parser was installed by someone else. The thing is I'm not sure how to install LiveQuery for my server. I don't know if my version of server is good for this kind of operations. I found some solutions how to enable this feature, but there was something like "index.js" - in my file system it's app.js. Screen of file system
In app.js i added lines:
liveQuery: {
classNames: ["Test"] //List of classes to support for query subscritions
}
I've created class in my db named "Test", then i found solution i need to add
this line
liveQueryUrl: keyLiveQueryUrl, // Required if using LiveQuery
I don't really know how to get this key.
How can i check if LiveQuery works? It will be used by flutter code, but i'd like to check it first in PHP.
My problem has been solved in my other extended topic here.
Few weeks ago I set up a Message system with Symfony Messenger and it worked great.
Today I wanted to create new object through message, so I went to my server and type the command to consume message
First I had this result
$ bin/console messenger:consume-messages amqp_notifications
/usr/bin/env: ‘php\r’: No such file or directory
It never happened before with my files, and I never changed the line ending or encoding of my file sin PHPstorm.
I tried to use $ php bin/console messenger:consume-messages amqp_notifications
but then I had this error.
Attempted to load class "AMQPConnection" from the global namespace.
Did you forget a "use" statement?
Pretty weird, because I have have the php-amqp ext installed as you can see on the screenshot of my phpinfo
I didn't change anything in my Message class or Handler.
Also, I tried to call new AMQPConnection() on a random action, just to try, and I didn't get the error.
I'm completely lost with this error this time, as everything is installed.
I use PHP 7.3.1 and symfony Messenger 4.2.2
It seems your second issue was already solved by ccKep on his comment.
The first one is that the specific shebang line #!/usr/bin/env php executes the first php found in the $PATH. So if you already have uninstalled it, which seems the case, or it has a symbolic link to another php version, you can get a wrong result.
Tries to check what is inside the $PATH and replace the PHP path for the correct one. You might get the place running which php.
I'm trying to use the API of a dutch site that's being used by schools in The Netherlands to keep track of the grades and other data of the students. You can find the documantation here: http://www.magister-api.nl/ (it's in Dutch).
I installed Wamp server and Composer, just like the documentation of the API tells. I also have the Curl PHP extension and Mcrypt PHP extension enabled in Wamp, just like the documentation tells.
I have the composer.json file in the project root with:
{
"require": {
"stanvk/magister": "~2.0"
}
}
I then executed Composer update.
The only code that I have is:
<?php
require 'vendor/autoload.php';
use Magister\Magister;
use Magister\Models\Grade\Grade;
new Magister($school, $username, $password);
$grades = Grade::all();
foreach ($grades as $grade)
{
echo $grade->CijferStr;
}
?>
It's the exact same code as given as example on the documentation website.
But when I then run it, I get these errors:
Errors
I tried a lot to solve the problem, but I can't seem to figure it out. It's the first time I'm using composer and packagist.
The first two errors are unrelated to composer or Wamp - you're simply using two variables that hasn't been defined, $username and $password (and possibly $school). The rest of the errors seems to stem from these having no value (the Magister object seems to try to request username.magister.net, and without a username .. that field is empty).
Provide the correct username and password and things will probably work as you expect.
I am using phpseclib to do some SFTP stuff. At the moment I can't login, and I am trying to find out why. In the docs, it states I should do something like this
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
include 'Net/SFTP.php';
define('NET_SFTP_LOGGING', NET_SFTP_LOG_COMPLEX);
$sftp = new NET_SFTP('***');
if(!$sftp->login('***', '***')) {
print_r($sftp->getSFTPErrors());
}
So, I need to define the type of logging in order to print out the SFTPErrors.
I am doing things differently than the above because I am using composer. So as usual, I load autoload.php. Instead of include, I make use of use e.g.
use phpseclib\Net\SFTP;
I then proceed to do something like the following
define('NET_SFTP_LOGGING', NET_SFTP_LOG_COMPLEX);
$sftp = new SFTP($config::SFTP_SERVER);
if(!$sftp->login($config::SFTP_USER, $config::SFTP_PASSWORD)) {
print_r($sftp->getSFTPErrors());
exit('Login Failed');
}
If I do this however, I get the output
Notice: Use of undefined constant NET_SFTP_LOG_COMPLEX - assumed 'NET_SFTP_LOG_COMPLEX' in ...
Array
(
)
Login Failed
So it appears that with composer, I cant define a constant in the same way, and the print out of the errors produces an empty array.
So, how can I define this constant in my composer project?
Thanks
A few of things.
If you're using the namespaced version of PHP (as evidenced by your use phpseclib\Net\SFTP;) then you're using the 2.0 branch. The documentation on the website is for the 1.0 branch. For the 2.0 branch you need to do as Félix Saparelli suggested - SSH2::LOG_COMPLEX.
That said, logging isn't going to show SFTP errors. Logging shows you the raw packets. Here's an example of what the logs produce:
http://phpseclib.sourceforge.net/ssh/log.txt
You get these logs by doing $ssh->getLogs().
For the errors you don't need to enable anything - it places any errors it receives from the server into an array that it's returning to you. phpseclib does this automatically and this behavior cannot be disabled.
Also, $sftp->getSFTPErrors() is great for SFTP errors but at the login process you might be getting SSH errors and not SFTP errors. You'd get SSH errors by doing $sftp->getErrors(). The thing is... SFTP operates in a higher layer than SSH. SSH won't succeed if TCP/IP can't make a connection and SFTP won't succeed if SSH can't make a connection. So per that you ought to be checking all the layers.
Finally, it's quite possible the failure is happening for reasons for which errors would not be returned. Maybe the server requires compression, which phpseclib doesn't support. eg.
http://www.frostjedi.com/phpbb3/viewtopic.php?p=221481#p221481
I also don't know if you'd get an error if the key or password you were using was simply invalid.
Really, there could be any number of causes for an inability to connect. You could be using selinux which, by default, disables outbound connections from PHP scripts running on port 80, there could be a routing issue, etc (all of these affect fsockopen, but, in all, there are just a lot of potential causes for failure).
Overall, I'd say you're on the right track with the logs. But do $sftp->getLog() instead of $sftp->getSFTPErrors() and then include the logs in your post.
I just finished to install Ingres on my server(only the client part, to connect to an existing ingres server), I just added the php_ingres module.
Now php recognize my module, so I tried to connect my self to several existing servers, but I always a
Unable to connect to database (Hostname here)
But with this I can't find what is wrong?? ingres error? Php driver? Credentials? ...?
What can I do to isolate these problem?
Most likely it's a user credentials issue. To see the actual error message use the following code:
$connection = ingres_connect(.....);
if (!is_resource($connection))
{
trigger_error(ingres_errno()." - ". ingres_error(),E_USER_ERROR);
}
You might also want to take a look at http://community.ingres.com/wiki/Ingres_with_Apache_on_Debian_Etch which outlines the setup steps for Ingres, PHP, Apache and Debian/Ubuntu.