Closed bgaillard closed 8 years ago
as requested:
if (isset($_GET['doit3'])) {
require(dirname(__DIR__).'/Gomoob/Pushwoosh/Client/Pushwoosh.php');
print 'pushwoosh';
try {
$pushwoosh = Pushwoosh::create()
->setApplication('MY APP CODE HERE')
->setAuth('MY AUTH HERE');
} catch(Exception $e) {
print 'feck it';
print $e->getMessage();
}
// Create a request for the '/createMessage' Web Service
$request = CreateMessageRequest::create()
->addNotification(Notification::create()->setContent('Hello Jean !'));
// Call the REST Web Service
$response = $pushwoosh->createMessage($request);
// Check if its ok
if($response->isOk()) {
print 'Great, my message has been sent !';
} else {
print 'Oops, the sent failed :-(';
print 'Status code : ' . $response->getStatusCode();
print 'Status message : ' . $response->getStatusMessage();
}
}
And my folder structure is like the attached screenie. I know i've done something silly, but its Friday!
Hi @corse-xx,
Here is a code sample which works without composer.
<?php
require_once 'php-pushwoosh-master/src/main/php/Gomoob/Pushwoosh/ICURLClient.php';
require_once 'php-pushwoosh-master/src/main/php/Gomoob/Pushwoosh/IPushwoosh.php';
require_once 'php-pushwoosh-master/src/main/php/Gomoob/Pushwoosh/Client/CURLClient.php';
require_once 'php-pushwoosh-master/src/main/php/Gomoob/Pushwoosh/Client/Pushwoosh.php';
require_once 'php-pushwoosh-master/src/main/php/Gomoob/Pushwoosh/Model/Notification/ADM.php';
require_once 'php-pushwoosh-master/src/main/php/Gomoob/Pushwoosh/Model/Notification/Android.php';
require_once 'php-pushwoosh-master/src/main/php/Gomoob/Pushwoosh/Model/Notification/BlackBerry.php';
require_once 'php-pushwoosh-master/src/main/php/Gomoob/Pushwoosh/Model/Notification/IOS.php';
require_once 'php-pushwoosh-master/src/main/php/Gomoob/Pushwoosh/Model/Notification/Mac.php';
require_once 'php-pushwoosh-master/src/main/php/Gomoob/Pushwoosh/Model/Notification/MinimizeLink.php';
require_once 'php-pushwoosh-master/src/main/php/Gomoob/Pushwoosh/Model/Notification/Notification.php';
require_once 'php-pushwoosh-master/src/main/php/Gomoob/Pushwoosh/Model/Notification/Platform.php';
require_once 'php-pushwoosh-master/src/main/php/Gomoob/Pushwoosh/Model/Notification/Safari.php';
require_once 'php-pushwoosh-master/src/main/php/Gomoob/Pushwoosh/Model/Notification/WNS.php';
require_once 'php-pushwoosh-master/src/main/php/Gomoob/Pushwoosh/Model/Notification/WP.php';
require_once 'php-pushwoosh-master/src/main/php/Gomoob/Pushwoosh/Model/Request/CreateMessageRequest.php';
require_once 'php-pushwoosh-master/src/main/php/Gomoob/Pushwoosh/Model/Response/AbstractResponse.php';
require_once 'php-pushwoosh-master/src/main/php/Gomoob/Pushwoosh/Model/Response/CreateMessageResponse.php';
use Gomoob\Pushwoosh\Client\Pushwoosh;
use Gomoob\Pushwoosh\Model\Request\CreateMessageRequest;
use Gomoob\Pushwoosh\Model\Notification\Notification;
// Configure the Pushwoosh client
$pushwoosh = Pushwoosh::create()->setApplication('MY APP CODE HERE')->setAuth('MY AUTH HERE');
// Create a request for the '/createMessage' Web Service
$request = CreateMessageRequest::create()->addNotification(Notification::create()->setContent('Hello Jean !'));
// Call the REST Web Service
$response = $pushwoosh->createMessage($request);
// Check if its ok
if($response->isOk()) {
print 'Great, my message has been sent !';
} else {
print 'Oops, the sent failed :-(';
print 'Status code : ' . $response->getStatusCode();
print 'Status message : ' . $response->getStatusMessage();
}
The best advice I can give you is ALWAYS USE COMPOSER IF YOU CAN ! : https://getcomposer.org.
Anyway others have the same problems so I think I'll simply create a script which produces an includes.php
file to be able to only do that if we do not have composer :
require_once 'php-pushwoosh-master/src/main/php/Gomoob/Pushwoosh/includes.php';
...
Hiya and thank you for the quick response. I implemented that but its not executing either. If i put a quick print statement like print 'here'; in before the require_once statements and then execute then i get nothing, but if i remove from the use statement on and execute then i get the print statement. Something is definitely happening within the namespace that is not being pushed back.
Strange, I think you have an error elsewhere or a configuration problem, in my opinion php-pushwoosh is not the cause of your problem here, perhaps ...
Also besides using print
take the time to configure your PHP environment to write error logs inside a file, it will definitly help you.
I chucked the code up to a test server i have in the US to see if i got anything different (to be sure that PHP install wasn't causing an issue here) and eh voila i get an error message of:
Fatal error: Class 'Gomoob\Pushwoosh\Model\Response\CreateMessageResponseResponse' not found in /home/mypathtofiles/php-pushwoosh-master/src/main/php/Gomoob/Pushwoosh/Model/Response/CreateMessageResponse.php on line 40
:+1: Ok, so now check the file is their, check you have the right UNIX rights on your files and directories and you downloaded a not corruped zip https://github.com/gomoob/php-pushwoosh/archive/master.zip ;-).
Add do not forget to add this before the CreateMessageResponse.php
require...
require_once 'php-pushwoosh-master/src/main/php/Gomoob/Pushwoosh/Model/Response/CreateMessageResponseResponse.php';
was just the declaration :) all working now so its the local php and i really need to go shout at my environment creator :p thank you Baptiste!
Closing this because no serious PHP developer should use PHP without composer (or at least if absolutly needed this is absolutly not the responsibility of php-pushwoosh).
Several users encounter difficulties to use the library without composer :
We should explain how to use the library without composer, a code sample will also help.