Git Product home page Git Product logo

Comments (9)

corse-xx avatar corse-xx commented on June 4, 2024

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!
folders

from php-pushwoosh.

bgaillard avatar bgaillard commented on June 4, 2024

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.

corse-xx avatar corse-xx commented on June 4, 2024

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.

bgaillard avatar bgaillard commented on June 4, 2024

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.

from php-pushwoosh.

corse-xx avatar corse-xx commented on June 4, 2024

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.

bgaillard avatar bgaillard commented on June 4, 2024

👍 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.

bgaillard avatar bgaillard commented on June 4, 2024

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.

corse-xx avatar corse-xx commented on June 4, 2024

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.

bgaillard avatar bgaillard commented on June 4, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.