PHP code example of passkit / passkit-php-grpc-sdk

1. Go to this page and download the library: Download passkit/passkit-php-grpc-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

passkit / passkit-php-grpc-sdk example snippets




putenv("GRPC_SSL_CIPHER_SUITES=HIGH+ECDSA");

$ca_filename = "ca-chain.pem";
$key_filename = "key.pem";
$cert_filename = "certificate.pem";
$path = "../certs/";

$credentials = Grpc\ChannelCredentials::createSsl(
    file_get_contents($path . $ca_filename),
    file_get_contents($path . $key_filename),
    file_get_contents($path . $cert_filename)
);

$client = new Members\MembersClient('grpc.pub1.passkit.io:443', [
    'credentials' => $credentials
]);


nv("GRPC_SSL_CIPHER_SUITES=HIGH+ECDSA");

try {
    $ca_filename = "ca-chain.pem";
    $key_filename = "key.pem";
    $cert_filename = "certificate.pem";
    $path = "../certs/";

    $credentials = Grpc\ChannelCredentials::createSsl(
        file_get_contents($path . $ca_filename),
        file_get_contents($path . $key_filename),
        file_get_contents($path . $cert_filename)
    );

    $client = new Members\MembersClient('grpc.pub1.passkit.io:443', [
        'credentials' => $credentials
    ]);

    // Set the Member body
    $member = new Members\Member();
    $member->setProgramId("5fbCcr7f4NuBg9lvjJayvV");
    $member->setTierId("bronze");

    $person = new Io\Person();
    $person->setDisplayName("Patrick Kosterman");
    $dateOfBirth = new Io\Date();
    $dateOfBirth->setDay(22);
    $dateOfBirth->setMonth(6);
    $dateOfBirth->setYear(2020);
    $person->setDateOfBirth($dateOfBirth);
    $person->setEmailAddress("[email protected]");
    $member->setPerson($person);

    list($id, $status) = $client->enrolMember($member)->wait();
    if ($status->code !== 0) {
        throw new Exception(sprintf('Status Code: %s, Details: %s, Meta: %s', $status->code, $status->details, var_dump($status->metadata)));
    }

    echo "https://pub1.pskt.io/" . $id->getId();
} catch (Exception $e) {
    echo $e;
}
json
{
  "repositories": [
    {
      "type": "git",
      "url": "https://github.com/passkit/passkit-php-grpc-sdk.git"
    }
  ],
  "