Code Monkey home page Code Monkey logo

freshdesk-php-sdk's Introduction

Freshdesk PHP SDK API v2

Build Status Scrutinizer Code Quality SensioLabsInsight Packagist

This is a PHP 5.5+ SDK for the Freshdesk API v2.

If you have questions, please contact me or open an issue on GitHub.

Quick Start

require __DIR__ . '/vendor/autoload.php';
use \Freshdesk\Api;

$api = new Api("your_freshdesk_api_key", "your_freshdesk_domain");

$all = $api->tickets->all();
$some = $api->tickets->all(['page' => 2]);
$new = $api->tickets->create($data);
$updated = $api->tickets->update($data);
$api->tickets->delete($id);
$existing = $api->tickets->view($id);

//Responses are simple arrays, e.g.:
$id = $existing['id'];
$first = $all[0];

Framework Integration

Installation

To integrate this library into your application, use Composer.

Add mpclarkson/freshdesk-php-sdk to your composer.json file:

{
    "require": {
        "mpclarkson/freshdesk-php-sdk": "dev-master"
    }
}

Then run:

php composer.phar install

API Overview

Full documentation is available here

Getting started

Creating a new API instance is very easy. All you need is your Freshdesk API key and your Freshdesk domain.

require __DIR__ . '/vendor/autoload.php';
use \Freshdesk\Api;

$api = new Api("your_freshdesk_api_key", "your_freshdesk_domain");

Resources

The available methods for each resource are available via a public property on the api, for example:

//Contacts
$contacts = $api->contacts->update($contactId, $data);

//Agents
$me = $api->agents->current();

//Companies
$company = $api->companies->create($data);

//Groups
$deleted = $api->groups->delete($groupId);

//Tickets
$ticket = $api->tickets->view($filters);

//Time Entries
$time = $api->timeEntries->all($ticket['id']);

//Conversations
$ticket = $api->conversations->note($ticketId, $data);

//Categories
$newCategory = $api->categories->create($data);

//Forums
$forum = $api->forums->create($categoryId, $data);

//Topics
$topics = $api->topics->monitor($topicId, $userId);

//Comments
$comment = $api->comments->create($forumId);

//Email Configs
$configs = $api->emailConfigs->all();

//Products
$product = $api->products->view($productId);

//Business Hours
$hours = $api->businessHours->all();

//SLA Policy
$policies = $api->slaPolicies->all();

Responses

All responses are arrays of data. Please refer to Freshdesk's documentation for further information.

Filtering

All GET requests accept an optional array $query parameter to filter results. For example:

//Page 2 with 50 results per page
$page2 = $this->forums->all(['page' => 2, 'per_page' => 50]);

//Tickets for a specific customer
$tickets = $this->tickets->view(['company_id' => $companyId]);

Please read the Freshdesk documentation for further information on filtering GET requests.

Contributing

This is a work in progress and PRs are welcome. Please read the contributing guide.

Nearly all api calls are available except for the Solutions and Surveys, which Freshdesk has not yet implemented.

  • Solutions
  • Surveys
  • Uploading files is not yet supported
  • More tests. You can never have enough!
  • Nicer documentation

Author

The library was written and maintained by Matthew Clarkson from Hilenium.

Reference

freshdesk-php-sdk's People

Contributors

gielwijgergangs avatar gtapps avatar mpclarkson avatar onehatrepo avatar scrutinizer-auto-fixer avatar vdechenaux 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

Watchers

 avatar  avatar  avatar  avatar  avatar

freshdesk-php-sdk's Issues

how to handle exception using Freshdesk API.

try{
$tickets = Freshdesk::tickets()->all(['tag'=>'Lead']);
dd($tickets);
}catch(\Exception $e) {
echo $response = $e->getResponse();

    }

its not showing error response ?
I am using Lumen and installed freshdesk sdk via composer

Guzzle 5 vs 6 client creation difference

First of all, thank you for this code!

I have 2 projects I am including it in, both of which have existing packages with guzzle dependencies.

In the project with guzzlehttp/guzzle 6.3.0 your code works fine.

In my project with guzzlehttp/guzzle 5.3.1 I was receiving a "401 unauthorized" error. I fixed this by changing your code in Api.php to $this->client = new Client([ 'defaults' => [ 'auth' => [$apiKey, 'X'] ] ] );

Additionally, I had a hard time catching this error. The exceptions don't seem to be "bubbling up" to get caught.

Thanks again.

Update Guzzlehttp to v6

Could you please update Guzzle HTTP to v6 ?
Tons of other laravel software depends on it and other version causes incompatibilities.

Update Guzzlehttp to v7

Laravel released version 8 recently. It requires guzzlehttp/guzzle 7.0.1 (upgrade docs). It appears v3.1 of freshdesk-php-sdk requires >=4.0,<7.0:

$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install guzzlehttp/guzzle 7.0.1
    - Conclusion: don't install guzzlehttp/guzzle 7.1.x-dev
    - mpclarkson/freshdesk-php-sdk 0.3.1 requires guzzlehttp/guzzle >=4.0,<7.0 -> satisfiable by guzzlehttp/guzzle[4.x-dev, 5.3.x-dev, 6.5.x-dev].
    - mpclarkson/freshdesk-php-sdk 0.3.1 requires guzzlehttp/guzzle >=4.0,<7.0 -> satisfiable by guzzlehttp/guzzle[4.x-dev, 5.3.x-dev, 6.5.x-dev].
    - Can only install one of: guzzlehttp/guzzle[7.0.x-dev, 5.3.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.0.x-dev, 4.x-dev].
    - Installation request for guzzlehttp/guzzle ^7.0.1 -> satisfiable by guzzlehttp/guzzle[7.0.1, 7.0.x-dev, 7.1.x-dev].
    - Installation request for mpclarkson/freshdesk-php-sdk ^0.3.1 -> satisfiable by mpclarkson/freshdesk-php-sdk[0.3.1].

Similar to issue #8 , can we get updates for guzzle 7.0.1 please?

API Errors when Filtering for Companies

I'm guessing this is an encoding issue, but I haven't been able to correct it as of yet. When using the filtering capabilities documented in the Freshdesk API for searching companies by domain I receive the following error: "Unexpected/invalid field in request"

After some testing I was able to get the following curl request to work from the command line, but I can't reproduce the same result in code.

curl -v -u {API_KEY}:X -X GET 'https://{DOMAIN}.freshdesk.com/api/v2/search/companies?query="domain:%27gmail.com%27"'

The key seems to be encoding the single quotes in the query, but not the double quotes surrounding it, at least from the curl CLI. I tried a number of combinations from the PHP library and can't seem to get it to go through.

$arrCompanies = $this->objFreshdesk->companies->all([
'query' => '"domain:'gmail.com'"',
]);

Merge Ticket Correspondences – Ticket System Freshdesk x Beds24

Hoping you might can help us with this?

We are a host of long and short time rent and are offering various services (cleaning, hosting customers, bricolages, etc.) for our own but also for other owners of apartments/houses all over our city. Respective ads are placed on portals such as Airbnb and Booking.Com <- most of the customer communications are also flowing via these.

Here now the following. To channel all respective customer request via one tool, we decided to use the Ticket Management Tool from “Freshdesk”, important to not is also that our channel manager for this is Beds24 Problem: At the moment Airbnb and booking.com are sending all guest requests via API to beds24 and also to our email. The ticket creation comes from those emails which we forward to freshdesk. In some cases we can’t combine separate coherent tickets together. Freshdesk is requesting to have the same email address applied to identify the contact and auto combine the tickets and respective correspondences.
 Airbnb for example creates new email addresses per each request from a customer, making it impossible to have one string of correspondences in Freshdesk. Solution Proposal: Creating the tickets and contacts via API connection between beds24 or AirBnB/booking.com and freshdesk. Where each booking with a request gets create a ticket. Please contact us back in case you do already have a solution for our problem.

ApiException No message

Having issues with this and Laravel 5.7 module. Both return same issue with no real diagnosis.
Any api call returns API Exception: No Message

codesample
error sample

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.