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.
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.
I tried to implement the simplesamlphp library into my web application. But when I call the requireAuth() function I get a PHP fatal error message. Uncaught Exception: Loader: Illegal character in filename.....
It seems like he can't resolve the Class SimpleSAML\Module\saml\Auth\Source\SP
But I don't know why.
Does anyone have a idea how to fix this?
I already deleted the whole simplesamlphp installation and reinstalled it.
I use the following code:
require 'var/www/simplesamlphp/lib/_autoload.php';
$lAuthSrc = new \SimpleSAML\Auth\Simple('default-sp');
if (!$lAuthSrc->isAuthenticated()) {
$lAuthSrc->requireAuth();
}
$lAttributes = $lAuthSrc -> getAttributes();
foreach($lAttributes as $lAttribute) {
print_r($lAttribute);
}
Some additional informations:
The configured authentication source test works fine. If I login via the configured authentication source, everything works fine and I don't get any error messages (the requireAuth() function don't get called in this case).
I use the latest version of simplesamlphp v.1.18.3
If you need any more information, please let me know.
Honestly it looks like your path is messed up on the require... are you sure you should be using:
require 'var/www/simplesamlphp/lib/_autoload.php';
and not
require '/var/www/simplesamlphp/lib/_autoload.php';
Do you really have a 'var/www' subdirectory relative to the location of the script? That looks wrong to me. If you include that first / before var it makes that path absolute to the typical install location for SSP.
Thank you all for your help. I discovered this morning the issue. The issue was the autoloader which I use for my own application. I registered the application autoloader in another file which gets executed before the code you see above. And simplesamlphp uses some conditions like:
if (!class_exists($className))
And beacuse I registered my application autoloader before the function class_exists checked if the class exists in my application. In my application I don't use namespaces and this was the issue.
To fix this issue, I unregistered my application autoloader before using the simplesamlphp code and registered the autoloader again after the simplesamlphp code.
I hope this will save some of you headaches.
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.
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'm using this library to implement the Nexmo SMS service on my server. I required the library using Composer like so:
"require" : {
"prawnsalad/nexmo": "dev-master"
}
which I found here and followed the instructions included in the README like so:
require 'vendor/autoload.php';
use NexmoMessage;
$phone = '123456789';
$sms = new NexmoMessage(NEXMO_KEY, NEXMO_SECRET);//defined in another file
$sms->sendText($phone, 'from', "yo");//$phone is a valid number in actual case
However I keep getting the error in the title of this question. I see that Composer has imported the library successfully and I see the class and constructor for NexmoMessage, yet for some reason this error keeps happening no matter what I do. I'm not sure if this is due to an issue with the library or with how I'm using Composer. I've never had an issue with Composer in the past so I'm boggled why this is happening here. Thanks
Well, that library states that it supports PSR-4, which means they absolutely MUST use PHP namespaces, but they don't. That last commit 8 months ago https://github.com/prawnsalad/Nexmo-PHP-lib/commit/8e422c4f8f43c52acb70ebd5f9e7c6ff81a1f352 broke the autoloading. And nobody noticed up to today.
You can easily tell by looking at the source code: There is no namespace being used.
Your best action now would be to fix this issue and send a pull request! Github allows to edit files in the browser! Second best action would be to create an issue and let the authors know.