Comments (9)
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!
from php-pushwoosh.
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';
...
from php-pushwoosh.
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.
from php-pushwoosh.
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 ...
- You made a mistake elsewhere
- You use a very old PHP version, namespaces and use statements are supported since PHP 5.3 (http://php.net/manual/en/language.namespaces.importing.php). Our library is supported since PHP 5.3 (I cannot guaranty it is working with older PHP versions).
Also besides using print
take the time to configure your PHP environment to write error logs inside a file, it will definitly help you.
from php-pushwoosh.
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
from php-pushwoosh.
👍 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 ;-).
from php-pushwoosh.
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';
from php-pushwoosh.
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!
from php-pushwoosh.
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).
from php-pushwoosh.
Related Issues (20)
- PushwooshMock - Abstract method not implemented
- Internal Server Error and vendor folder HOT 7
- Internal Server Error When calling the sample code HOT 6
- Add Algolia doc search HOT 1
- Composer install problems with phpdocumentor HOT 1
- Hey from Pushwoosh! HOT 1
- getMock() undefined in unit tests with HHVM, any idea ? HOT 2
- Run tests with PHP 7.1 HOT 1
- Chrome and Firefox support in RegisterDeviceRequest
- Add a SensioLabs Insight badge
- Be compliant with all PSR naming conventions
- Implement new requests HOT 2
- CreateMessageResponse does not pass along UnknownDevices
- setCURLClient documentation wrong HOT 2
- No DefaultTimeOut HOT 3
- Create a Guzzle HTTP client
- Add `use XXXX` namespaces to examples and readme
- Is this repo still maintained ? HOT 2
- Send push notification only to testDevice
- PHP 8 support?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-pushwoosh.