Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in executing test script #81

Closed
fbartolom opened this issue Oct 23, 2019 · 8 comments
Closed

Error in executing test script #81

fbartolom opened this issue Oct 23, 2019 · 8 comments
Labels

Comments

@fbartolom
Copy link

I personalised the test script with my app information to get:

<?php
//require __DIR__ . '/vendor/autoload.php';

use Pushok\AuthProvider;
use Pushok\Client;
use Pushok\Notification;
use Pushok\Payload;
use Pushok\Payload\Alert;

$options = [
    'key_id' => '255YU6R88K', // The Key ID obtained from Apple developer account
    'team_id' => 'GF9PQ87F68', // The Team ID obtained from Apple developer account
    'app_bundle_id' => 'com.augmentedReality.virtualTags', // The bundle ID for app obtained from Apple developer account
    'private_key_path' => 'AuthKey_255YU6R88K.p8', // Path to private key
    'private_key_secret' => null // Private key secret
];

$authProvider = AuthProvider\Token::create($options);

$alert = Alert::create()->setTitle('Hello!');
$alert = $alert->setBody('First push notification');

$payload = Payload::create()->setAlert($alert);

//set notification sound to default
$payload->setSound('default');

//add custom value to your notification, needs to be customized
$payload->setCustomValue('key', 'value');

$deviceTokens = ['4303AC16C13448D4820345994E898FBD1EE95DD6B702B0133E5C065808FA8BE7'];

$notifications = [];
foreach ($deviceTokens as $deviceToken) {
    $notifications[] = new Notification($payload,$deviceToken);
}

$client = new Client($authProvider, $production = false);
$client->addNotifications($notifications);



$responses = $client->push(); // returns an array of ApnsResponseInterface (one Response per Notification)

foreach ($responses as $response) {
    $response->getApnsId();
    $response->getStatusCode();
    $response->getReasonPhrase();
    $response->getErrorReason();
    $response->getErrorDescription();
}
?>

commenting out the first line that linked nowhere, but I get error:

PHP Fatal error: Uncaught Error: Class 'Pushok\AuthProvider\Token' not found in /var/www/html/php/push/comodoPush.php:18
Stack trace:
#0 {main}
thrown in /var/www/html/php/push/comodoPush.php on line 18

@edamov
Copy link
Owner

edamov commented Oct 23, 2019

You need to require __DIR__ . '/vendor/autoload.php'

@fbartolom
Copy link
Author

Fine, I did not notice the new directory: now I have:

PHP Warning: Use of undefined constant CURLMOPT_MAX_HOST_CONNECTIONS - assumed 'CURLMOPT_MAX_HOST_CONNECTIONS' (this will throw an Error in a future version of PHP) in /var/www/html/php/push/vendor/edamov/pushok/src/Client.php on line 98
PHP Warning: curl_multi_setopt() expects parameter 2 to be int, string given in /var/www/html/php/push/vendor/edamov/pushok/src/Client.php on line 98
PHP Notice: Trying to access array offset on value of type null in /var/www/html/php/push/vendor/edamov/pushok/src/Response.php on line 191

@edamov
Copy link
Owner

edamov commented Oct 24, 2019

I didn't test the library on PHP 7.4 yet. Seems those errors appeared in the new php version

@edamov edamov added the bug label Oct 24, 2019
@fbartolom
Copy link
Author

fbartolom commented Oct 24, 2019 via email

@edamov
Copy link
Owner

edamov commented Oct 25, 2019

Unfortunately I don't have MacBook and Apple developer account for testing pushes with new PHP version soon.
Maybe you can help me with PR?

@fbartolom
Copy link
Author

I wonder thereafter why you pushed me to install all those pieces of new software, if you did not have any way to test it. What do you mean by PR?

@edamov
Copy link
Owner

edamov commented Oct 26, 2019

It's open source library. I worked on it when I had free time and possibility.
I didn't push you to install it, I just wanted to help you. If you want, you can use any other library on your choice.
PR - pull request. You can investigate the issue and send me changes, and I will merge them into the library.

@rasmusbe
Copy link
Contributor

I just ran the unit tests (including those in #89) in the latest 7.4RC and all tests did pass. BUT the unit tests does not test the curl connections.

But I also see that the constant CURLMOPT_MAX_HOST_CONNECTIONS should be available since PHP 7.0.7 and cURL 7.30.0 so I guess you are running some old version of php or curl.

@edamov edamov closed this as completed Apr 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants