Giter VIP home page Giter VIP logo

laravel-hubspot's Introduction

HubSpot PHP API Client Wrapper for Laravel

Latest Stable Version Total Downloads

This is a wrapper for the Hubspot/hubspot-api-php package and gives the user a Service Container binding and facade of the HubSpot\Discovery\Discovery class.

Installation

  1. composer require rossjcooper/laravel-hubspot
  2. Get a HubSpot API Key from the Intergrations page of your HubSpot account.
  3. Laravel 5.4 or earlier, in your config/app.php file:
    • Add Rossjcooper\LaravelHubSpot\HubSpotServiceProvider::class to your providers array.
    • Add 'HubSpot' => Rossjcooper\LaravelHubSpot\Facades\HubSpot::class to your aliases array.
  4. php artisan vendor:publish --provider="Rossjcooper\LaravelHubSpot\HubSpotServiceProvider" --tag="config" will create a config/hubspot.php file.
  5. Add your HubSpot API key and private app access token into the .env file: HUBSPOT_ACCESS_TOKEN=yourApiKey
  6. If you use the private app access token, you should alo add HUBSPOT_USE_OAUTH2=true to your .env file

Usage

You can use either the facade or inject the HubSpot class as a dependency:

Facade

// Echo all contacts first and last names
$response = HubSpot::crm()->contacts()->basicApi()->getPage();
    foreach ($response->getResults() as $contact) {
        echo sprintf(
            "Contact name is %s %s." . PHP_EOL,
            $contact->getProperties()['firstname'],
            $contact->getProperties()['lastname']
        );
    }
Route::get('/', function (HubSpot\Discovery\Discovery $hubspot) {
    $response = $hubspot->crm()->contacts()->basicApi()->getPage();
    foreach ($response->getResults() as $contact) {
        echo sprintf(
            "Contact name is %s %s." . PHP_EOL,
            $contact->getProperties()['firstname'],
            $contact->getProperties()['lastname']
        );
    }
});
// Create a new contact
$contactInput = new \HubSpot\Client\Crm\Contacts\Model\SimplePublicObjectInputForCreate();
$contactInput->setProperties([
    'email' => '[email protected]'
]);

$contact = $hubspot->crm()->contacts()->basicApi()->create($contactInput);

For more info on using the actual API see the main repo Hubspot/hubspot-api-php

Testing

We're using the brilliant Orchestra Testbench to run unit tests in a Laravel based environment. If you wish to run tests be sure to have a HubSpot API key inside your .env file and run composer run test

Current unit test access the HubSpot API and expect to see the demo contacts/leads that HubSpot provides to its developer accounts.

Issues

Please only report issues relating to the Laravel side of things here, main API issues should be reported here

laravel-hubspot's People

Contributors

benyanke avatar brenthays avatar callmetwan avatar chrispecoraro avatar limatheus avatar mtmail avatar omacranger avatar rossjcooper avatar wgriffioen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

laravel-hubspot's Issues

How to create a contact

At this moment I fetch the contacts like this:

Route::get('/', function (Rossjcooper\LaravelHubSpot\HubSpot $hubspot) {
    $response = $hubspot->contacts()->all();
    foreach ($response->contacts as $contact) {
        echo sprintf(
            "Contact name is %s %s." . PHP_EOL,
            $contact->properties->firstname->value,
            $contact->properties->lastname->value
        );
    }
});

How can I make a post request to create a contact?

Compatibility with api v3

Actually your package use HubSpot/hubspot-php , but there is the new repo HubSpot/hubspot-api-php that uses api v3.
Do you want to update your package to support the new one?

Class 'SevenShores\Hubspot\Resources\Contactlists' not found

First, thanks for making this wrapper! Apologies if this is not the appropriate forum for this question, but I thought I would start here.

I am trying to sync contact lists from my application to Hubspot, and everything is working locally. However, when I deploy my project to staging, I am getting this error:

Symfony\Component\Debug\Exception\FatalThrowableError: Class 'SevenShores\Hubspot\Resources\Contactlists' not found in /vendor/hubspot/hubspot-php/src/Factory.php:83

I have confirmed that the vendor directory and hubspot package are present on the staging server. I do notice the the class name is in title case such that the namespace is SevenShores\Hubspot\Resources\ContactLists. I'm not sure why this would work locally, but not in staging?

Here is my code that is calling the API:

// Add to HubSpot list
            HubSpot::contactlists()->addContact(env('HUBSPOT_LIST_ID'), [
                $contactId
            ], [
                $email
            ]);

I'm going to make a reference in the hubspot repo as well. Thanks for your work and feedback!

UPDATE

Ok, quick update here. I thought I would try referencing the resource (i.e. ContactLists) using camelCase through the facade: HubSpot::contactLists(). This fixed the issue. I am still unsure why it works locally but not in staging.

Thanks!

Turn http_errors off

When using the facade, is there a way to turn off http_errors? For example:
HubSpot::contacts()->getByToken($_COOKIE['hubspotutk']);

Laravel 8 Guzzle 7.0.1 support

Can you profive a support for Laravel 8?

Problem 1

  • Installation request for rossjcooper/laravel-hubspot ^3.0 -> satisfiable by rossjcooper/laravel-hubspot[3.0.0].
  • Can only install one of: guzzlehttp/guzzle[7.0.1, 6.5.x-dev].
  • Can only install one of: guzzlehttp/guzzle[7.0.x-dev, 6.5.x-dev].
  • Can only install one of: guzzlehttp/guzzle[7.1.0, 6.5.x-dev].
  • Can only install one of: guzzlehttp/guzzle[7.1.1, 6.5.x-dev].
  • Can only install one of: guzzlehttp/guzzle[7.1.x-dev, 6.5.x-dev].
  • Conclusion: install guzzlehttp/guzzle 6.5.x-dev
  • Installation request for guzzlehttp/guzzle ^7.0.1 -> satisfiable by guzzlehttp/guzzle[7.0.1, 7.0.x-dev, 7.1.0, 7.1.1, 7.1.x-dev].
    `

private apps

Does support private apps?
Starting November 30, 2022, HubSpot API keys will no longer be able to be used as an authentication method to access HubSpot APIs.

Is the ReadMe instruction is still updated?

Hi,

I'm wondering if the instruction in the ReadMe still updated and also I wonder how to use this inside the controller for instance I want to create a contact.

How do I call the SimplePublicObjectInput() from the wrapper, similar to HubSpot/hubspot-api-php example?

$contactInput = new \HubSpot\Client\Crm\Contacts\Model\SimplePublicObjectInput();
$contactInput->setProperties([
    'email' => '[email protected]'
]);

$contact = $hubspot->crm()->contacts()->basicApi()->create($contactInput);

Update ryanwinchester/hubspot-php version

Hi, could you update the dependency ryanwinchester/hubspot-php to the latest version (v1.1.1)?
I noticed that there are some new methods that are missing in version 1.0.
Thank you

support for new hubspot api?

It appears this library is using Hubspot's legacy API and not their new one (hubspot/api-client).

Any plans to start using hubspot/api-client ?

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.