GithubHelp home page GithubHelp logo

webinarjam's Introduction

alt text

Build Status Total Downloads Latest Stable Version Codacy Badge Scrutinizer Code Quality License

WebinarJam API implementation for PHP >= 7.0

About

This is a WebinarJam API implementation for PHP (>= 7.0) as documented in the official website

Requirements

1.PHP >= 7.0 2.ext-curl

Installation

You can add WebinarJam as a dependency using the composer CLI:

composer require joseayram/webinarjam

Alternatively, you can specify WebinarJam as a dependency in your project's existing composer.json file:

{
     "require": {
        "joseayram/webinarjam": "~1.0.2"
    }
}

After installing, you need to require Composer's autoloader:

require 'vendor/autoload.php';

Usage

Instance

`use joseayram\WebinarJam;`

`$webinarJam = new WebinarJam(YOUR_API_KEY);`

Retrieve a full list of all webinars published in your account (getWebinars)

`$webinarJam->getWebinars();`

Get details about one particular webinar from your account (getWebinar)

`$webinarJam->getWebinar(YOUR_WEBICODE);`

Register a person to a specific webinar (addToWebinar)

`$webinarJam->addToWebinar($webinarID, $firs_name, $email);`

Full Parameters list for this method

# Parameter Type Required? Default
1 Webinar ID String Yes none
2 First Name String Yes none
3 E-mail String Yes none
4 Schedule Integer Yes 0
5 Last Name String No null
6 Ip Address String No null
7 Country Code Integer No null
8 Phone Integer No null

Credits

The package was build based on the work of Cory Thompson in his WebinarJam Gist

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

WebinarJam API implementation for PHP is open-sourced software licensed under the MIT license.

Copyright

The WebinarJam logo, trademark and product name are property of Genesis Digital LLC.

webinarjam's People

Contributors

joseayram avatar dependabot[bot] avatar

Watchers

Cory Thompson avatar James Cloos avatar  avatar Ciarán Flanagan avatar

Forkers

prachayapramong

webinarjam's Issues

ISSUE | return only WebinarJam Object

Hi,

I always have as return :

WebinarJam Object
(
[apiKey:protected] => 904b5bee-2389
)

My test files below.

TEST.PHP:
`<?php
echo ('Begin
');

require_once dirname(DIR) . DIRECTORY_SEPARATOR . 'biopharm' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'WebinarJam.php';

$detail = new WebinarJam('XXX_my_key_XXX');

$detail->getWebinars();

echo '

';
print_r($detail);
echo '
';

echo ('END
');
`

WebinaJam CLASS:
`<?php

class WebinarJam
{
protected const API_URL = 'https://api.webinarjam.com/everwebinar';

protected const CURL_OPTIONS = [
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT        => 60,
];

/**
 * WebinarJam API Key
 * @var string
 */
protected $apiKey;

/**
 * WebinarJam Class Constructor
 *
 * @param  string $apiKey WebinarJam API Key
 */
public function __construct(string $apiKey)
{
    $this->apiKey = $apiKey;
}

/**
 * Call to API URL through curl extension
 *
 * @param  string $endpoint WebinarJam API EndPoint
 * @return array $jsonResults
 */
protected function authenticatedCall(string $endpoint, array $params = []): array
{
    $curl = curl_init(self::API_URL . $endpoint);

    if (empty($this->apiKey)) {
        throw new \Exception('You must specify a valid WebinarJam API Key');
    }

    if (is_resource($curl)) {
        $params['api_key'] = $this->apiKey;
        curl_setopt_array($curl, self::CURL_OPTIONS);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
        $result = curl_exec($curl);

        if (false === $result) {
            $error = curl_error($curl);
            curl_close($curl);
            throw new \Exception($error);
        }

        curl_close($curl);

        $jsonResults = is_string($result) ? json_decode($result, true) : null;

        if (!is_array($jsonResults)) {
            throw new \Exception($result);
        }

        return $jsonResults;
    }

    return [];
}

/**
 * Retrieve a full list of all webinars published in your account
 * @return array Webinar List
 */
public function getWebinars(): ?array
{
    return $this->authenticatedCall('webinars');
}

/**
 * Get details about one particular webinar from your account
 *
 * @param  string $webinarId Webinar ID
 * @return array $webinar Webinar Details
 */
public function getWebinar(string $webinarId): ?array
{
    return $this->authenticatedCall('webinar', ['webinar_id' => $webinarId]);
}

/**
 * Register a person to a specific webinar
 *
 * @param string      $webinarId   Webinar ID (required)
 * @param string      $first_name  First Name (required)
 * @param string      $email       E-mail (required)
 * @param int         $schedule    Schedule (required)
 * @param string|null $last_name   Last Name (optional)
 * @param string|null $ipAddress   IP Address (optional)
 * @param int|null $countryCode Country Code (optional)
 * @param int|null $phone       Phone (optional)
 * @return array $webinar Webinar Details
 */
public function addToWebinar(
    string $webinarId,
    string $first_name,
    string $email,
    int $schedule = 0,
    string $last_name = null,
    string $ipAddress = null,
    int $countryCode = null,
    int $phone = null
): array {
    $params = [
        'webinar_id' => $webinarId,
        'first_name' => $first_name,
        'email' => $email,
        'schedule' => $schedule
    ];

    $params['last_name'] = $last_name ?? null;
    $params['ip_address'] = $ipAddress ?? null;
    $params['phone_country_code'] = $countryCode ?? null;
    $params['phone'] = $phone ?? null;

    return $this->authenticatedCall('register', $params);
}

}
`

When i use false API_KEY i have 404 error, with the good key it return WebinarJam Object, have SSL issue ? (my website is HTTPS hosted by SITEGROUND)

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.