Code Monkey home page Code Monkey logo

zendesk_api_client_php's People

Contributors

7ail avatar andreionut avatar armen avatar atroche avatar bdav24 avatar buheryfi avatar chrisminett avatar cmourizard avatar devarispbrown avatar dpawluk avatar dqneo avatar ecoologic avatar ggrossman avatar ghermans avatar jaydiablo avatar jmramos02 avatar joseconsador avatar kcasas avatar lobaster avatar manted avatar maximeprades avatar mikealmond avatar miogalang avatar nogates avatar samgavinio avatar shanitang avatar shershennm avatar thekindofme avatar themelter avatar yoshdog 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  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  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  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

zendesk_api_client_php's Issues

Add support to make calls via a proxy server

I'd like to be able to use this from behind a proxy server. Can we add something like

$curl->setopt(CURLOPT_PROXY, $proxy);

to the Http.php file along with a setProxy function in the Client?

-micah

Unit tests written for specific zendesk instance.

Hey @maximeprades (and @zendesk/quokka),

I would like to chip into this project as well, but a lot of the unit tests are written in such a way it needs access to a specific (I'm guessing sandedboxy) zendesk instance.

For example this one: ForumsTest.php

It points to $forum = $this->client->forum(22480662)->find(); // don't delete forum #22480662

While you can instead of relying on an existing ticket, move this testFind() function to below the createTest() and use the outcome of that to test the testFind().

You guys have done this for some tests. For example: TargetsTest.php.

Is there a specific reason you guys have written the test like this or can I go ahead, rewrite some of the tests, so that all test will work with any zendesk instance and doesn't rely on certain tickets or forums to exists?

If you guys give me a heads up I will add that functionality and do a PR.

Class not found error

Using composer to include dev-master, when I updated to 52bdc2c, suddenly it causes a Zendesk\API\Client class not found. Changed composer.json to install dev-master#7177ef7 and it's working again.

Attachments are skewed when they arrive in ZenDesk

Here's my code:

$attachment = $zendesk->attachments()->upload(
    array(
            'file' => $file[0],
            'type' => $file[1]
    )
);
$token = $attachment->upload->token;
$zendesk->tickets()->create(
    array(
        'subject' => "Test",
        'description' => $description,
        'priority' => 'normal'
        "comment" => array(
            "body" => "Contact Form Attachment",
            "uploads" => array($token)
        )
));

The file and the ticket is being created correctly in the ZenDesk panel, however, a CSV rendered on the ZenDesk side like this:

------------------------------d57d8e1f7f8d
Content-Disposition: form-data; name="filename"; filename="/path/to/my/website/diretiory/media/contactfiles/file.csv" 
Content-Type: application/octet-stream

๏ฟฝ๏ฟฝ"CSV","Columns","1","2"
--------------------------d57d8e1f7f8d--

Where it should appear like this:

"CSV","Columns","1","2"

Images are then not rendered at all; but I think this is because the headers information is breaking the rendering code.

Make the API for IDE friendly.

First of all: Thank you for taking the time to make this API.

Being an avid PhpStorm-user, I miss my code-completions. Both for API-calls and the entities returned.

I realize this might make the API-client less maintainable, but ease and comfort of use is also important.

I will be using this client extensively for a web-project in the near-future. I might open a pull-request adding IDE-friendlyness, but I would be very happy if you could give some pointers how to go about it! :)

User Search via external_id no longer working

We have some code written against the v1 client to find users based on our external_id that no longer works (see below)

$result = $this->client->users()->search(array(
    'external_id' => sprintf('user-%s', $externalId),
));

Comparing the v1 and v2 code, it appears now that you're whitelisting query params between Http:: prepareQueryParams (

public static function prepareQueryParams(array $sideload = null, array $iterators = null)
{
$addParams = [];
// First look for side-loaded variables
if (is_array($sideload)) {
$addParams['include'] = implode(',', $sideload);
}
// Next look for special collection iterators
if (is_array($iterators)) {
foreach ($iterators as $k => $v) {
if (in_array($k, ['per_page', 'page', 'sort_order', 'sort_by'])) {
$addParams[$k] = $v;
}
}
}
return $addParams;
}
) and the code in Users->search (
$queryParams = isset($params['query']) ? ['query' => $params['query']] : [];
$extraParams = Http::prepareQueryParams($this->client->getSideload($params), $params);
) and as such are stripping out the external_id from the query params.

For local dev env reasons I've had trouble getting things set up to verify, but I think that when there are no params sent to search it returns anything that matches (everything), or at least that's my hunch because all our tickets lodged by signed in users are getting attached to our oldest user.

Would appreciate if you could confirm/fix, or just close it off if I'm mistaken.

API's grandiose exception handling problem!

Please revamp whole exception handling of the API so that every status code for exception cases are reflected correctly. E.g. instead of having one ResponseException let's have separate exceptions such as TooManyConnectionsException, MissingParameterException etc (and of course have unit-test-case for each exception handled). For every single status code at least. In it's current case, there is no way of managing the flow of code-logic, based upon the result's status code. E.g., it would be awesome to know before hand if one receives TooManyConnectionsException and upon the exception wait for necessary Retry-time seconds and try again.

With all due respect, this code needs very good peer-reviewing! It looks as if it was written for the sake of being written!

Regarding new ticket creation

Hello, I am using the new ticket creation code as follows but it is showing error "Trying to get property of non-object"...Please help.

"Help, my device is off!", "z_description"=>"help I need some help", "z_recipient"=>"[email protected]", "z_name"=>"Jacks Ferro", "z_requester"=>"[email protected]" ); $create = json_encode(array('ticket' => array('subject' => $arr['z_subject'], 'description' => $arr['z_description'], 'requester' => array('name' => $arr['z_name'], 'email' => $arr['z_requester']))), JSON_FORCE_OBJECT); $data = $zendesk->call("/tickets", $create, "GET"); print "hello test".$data->ticket->id; $test = $zendesk->test(); print "\n"; ?>

Thanks in advance.

Make release tag

Hello,

You could make some version as release?
This way when using with composer, you could use version instead of "dev-master" and that way prevent "unbound version constraints (dev-master) should be avoided" warning with composer.

Thanks!

It doesn't work

when initiating ZendeskAPI object it gives an error
$client = new ZendeskAPI($subdomain, $username);

Here is the error:

Catchable fatal error: Argument 1 passed to Zendesk\API\Search::search() must be an array, object given, called in /Webserver/htdocs/project/vendor/zendesk/zendesk_api_client_php/src/Zendesk/API/Client.php on line 90 and defined in /Webserver/htdocs/project/vendor/zendesk/zendesk_api_client_php/src/Zendesk/API/Search.php on line 13

If I comment $this->search = new Search($this); on the line 90 of the file vendor/zendesk/zendesk_api_client_php/src/Zendesk/API/Client.php it starts to work.

Fatal error: Class 'Zendesk\API\Client' not found

I've installed via Composer and in my php page (in the same directory as the vendor directory) I have copied this and put in my settings:

use Zendesk\API\Client as ZendeskAPI;

$subdomain = "subdomain";
$username = "username";
$token = "6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv"; // replace this with your token
// $password = "123456";

$client = new ZendeskAPI($subdomain, $username);
$client->setAuth('token', $token); // set either token or password

My page is giving the error: Fatal error: Class 'Zendesk\API\Client' not found

For more context, I'm trying to use the library as a plugin to my CMS system, but that shouldn't matter...

I'm using PHP Version 5.5.24...

Are there any troubleshooting steps I could take to help solve this?

Thanks!

Sean

Multiple Attachments?

It's not clear how to use this api client to add multiple attachments to a ticket, or if its even possible. My attempts result in only the last file actually getting attached. Has anyone been able to do this and if so do you mind sharing how?

Am I missing something

The example doesn't work, there is no vendor/autoload and i can't get access to methods

Users->findAll() bug found

Finding users with the roles "admin" and "agent" was resulting in a not working link.
zendesk.com/users.json&role[]=agent&role[]=admin

As we can see the link should be :
zendesk.com/users.json?role[]=agent&role[]=admin

Solution:
File: src\Zendesk\API\Users.php
Online: 43
&role[]='.implode('&role[]=', $params['role'])
Should be
?role[]='.implode('&role[]=', $params['role'])

Help Center API?

When can we expect the HC API to be added to the PHP API Client?
Many thanks!

Possible XSS and Information disclosure in Http::send

In the current dev-master the debug info is automatically printed if the response was >= 400.
The debug info may contain the authorization header, among other things.

Since the LastRequestHeaders is reflected, it is also possible to inject JS code if for instance the id wasn't validated properly in a search request.

    [...]
    if ($responseCode >= 400) {
        print($client->getDebug());
        throw new ResponseException(__METHOD__);
    }
    [...]

https://github.com/zendesk/zendesk_api_client_php/blob/master/src/Zendesk/API/Http.php#L149

v1.2.0 appears to be okay.
I did not check other parts of the code or other versions, though. I currently don't have the time. I just wanted to pass this information quickly.

How to get reason why ticket creation fails?

When trying to create tickets via API, I sometimes get following error:

Response to Zendesk\\API\\Tickets::create is not valid. Call $client->getDebug() for details

However, all I can get from getDebug() is HTTP code:

HTTP/1.1 422 Unprocessable Entity

Looking briefly at the source code, it is not possible to extract exact reason why entity is not valid. Or am I missing something?

Error completing request [url]

Hi,

I'm trying to use the SDK, but I cannot comunicate with zendesk.

I tryed to launch this code:

$client = new ZendeskAPI( $this->zendesk_domain, $this->zendesk_usr );
$client ->setAuth('basic', ['username' => $this->zendesk_usr, 'token' => $this->zendesk_pss ]);
$tickets = $client->tickets()->findAll();

But I receive this error:

Zendesk\API\Exceptions\ApiResponseException : Error completing request [url] https://yithemes1432719252.zendesk.com/api/v2/tickets.json [http method] GET [body]

I'm using the sandbox of zendesk and the email and token are correct, I already checked it.

Why am I having this problem?

Thanks.

Recommend an other verison than dev-master

Including dev-master feels unstable.

No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license. require.doctrine/dbal : unbound version constraints (*) should be avoided require.zendesk/zendesk_api_client_php : unbound version constraints (dev-master) should be avoided

Filter and search request

Hi There,

How do I filter the request?
I want to filter tickets creating (greather than) date like:

Ticket create more than 2015-09-01 and less than 2015-10-01;

How can I do that?
$tickets = $zendesk->tickets()->findAll(["created_at" => "2015-09"]);

And the search API is not documented, how do I use it?
There's some documentation to guide me?

I appreciate that!

Errors with $client->tickets()->create($ticket);

Filing an issue that changes introduced on May 5 have caused ticket creation to fail when using $client->tickets()->create($ticket);

Here are the error messages:

Warning: fopen({): failed to open stream: No such file or directory in Zendesk\API\Http::send() (line 49 of /vagrant/html/profiles/dosomething/libraries/zendesk/src/Zendesk/API/Http.php).
Warning: filesize(): stat failed for { in Zendesk\API\Http::send() (line 50 of /vagrant/html/profiles/dosomething/libraries/zendesk/src/Zendesk/API/Http.php).
Warning: fread() expects parameter 1 to be resource, boolean given in Zendesk\API\Http::send() (line 51 of /vagrant/html/profiles/dosomething/libraries/zendesk/src/Zendesk/API/Http.php).
Warning: curl_setopt(): supplied argument is not a valid File-Handle resource in Zendesk\API\Http::send() (line 53 of /vagrant/html/profiles/dosomething/libraries/zendesk/src/Zendesk/API/Http.php).

I've confirmed that if I checkout this commit 6aa9662 and run composer install, tickets will be created without an errors.

Update README to latest Zendesk client API

Please update the README file to reflect the recent changes to the dev-master version of the codebase.

In particular the code examples do not reflect the change of Zendesk\API\Client to Zendesk\API\HttpClient:

Class 'Zendesk\API\Client' not found

More importantly there is no mention to the fact token in no longer considered a valid authentication method:

Invalid auth strategy set, please use `basic` or `oauth`

Thanks.

Retrieve tickets requested by a user

How to retrieve tickets requested by a specific user in Zendesk PHP API Client V2?

In previous version I used this way

$tickets = $client->users($requesterId)->tickets()->findAll()

But in V2 there is no method called tickets available in Zendesk\API\Resources\Core\Users.

There is no reference about it in upgrade guide.

HC API missing

Hello. I don't know if I'm missing it, but where can I get things like Articles? Is there a separate HC API somewhere?

Thanks

XML Return

You can return the XML data with the REST API?

Undefined property: Zendesk\API\Resources\Core\Search::$results

I am using this api client in a laravel 4.2 project I have the following code:

public function GetClient()
{
    $client = new ZendeskAPI($this->zendesk['Subdomain'], $this->zendesk['Username']);
    $client->setAuth('basic', ['username' => $this->zendesk['Username'], 'token' => $this->zendesk['Token']]);
    return $client;
}

And I use it like this:

$client = $this->GetClient();
$query = 'type:organization name:"'.$zendesk_organisation_name.'"';
$params = array(
    'query' => $query
);
$organisations = $client->search($params);

This gives me the following error: Undefined property: Zendesk\API\Resources\Core\Search::$results

I have not been able to track down exactly where or how this error is occurring. This code worked fine before until I recently did a composer update. Has there been any major breaking changes?

zendesk_api_client_php

Hi,

After i Load my library directly by downloading from git repositoy.
I get the error as:

Fatal error: Class 'Zendesk\API\Debug' not found in C:\xampp\htdocs\Former\zendesk_api_client\src\Zendesk\API\Client.php on line 240

oAuth Bad Request

I am trying the example in oauth.php. I am able to get the authorisation code, but when I get redirected back to exchange the code for the token, I get this error:

HTTP/1.1 400 Bad Request

Open call for feedback

Hey guys, I've cc'd everyone who's contributed to this repo recently.

@miogalang, @joseconsador and I are about to start a week-long intensive on this project in the Manila office. What do you think we should work on? I've identified a few things so far:

  • Better exception handling (thanks @shehi and @ocke)
  • Better unit test coverage (thanks @ggrossman)
  • Full support for all endpoints in the core API
  • Higher code quality in general (using static analysis, if possible)
  • A consistent interface for resources (i.e. the constructors, getters, setters, etc. should all work the same whether you're working with apps, tickets or anything else)
  • More information in the README about what the library can do, and how to use it

Anything else you'd like to mention? Now's a good time =)

@mtibben @jurajseffer @andreionut @bvarent @ha-quidco @miogalang @jwswj @mmolina

PHP Fatal Error: Call to a member function getReasonPhrase() on a non-object

Using 04e31fb we're seeing the following error being thrown inside the Zendesk library:

vendor/zendesk/zendesk_api_client_php/src/Zendesk/API/Exceptions/ApiResponseException.php:22
Call to a member function getReasonPhrase() on a non-object

Given that it's a fatal error occurring inside the library we can't see the context in which this is occuring

Http-basic authentication does not work.

Tried authenticating by username/password, but got the following response: "Couldn't authenticate you". I then tried the url used directly in the browser, and was easily authenticated.

SSL peer verification disabled in Http.php

Hi,
Any specific reason that SSL peer verification is disabled for the API code? This would make it vulnerable to MITM attacks. It looks to me that we should make it always enabled instead.

findAll itertation is not working in PHP API

I have discovered, that parameters set to function findAll were not passed to the API call

current function

    /**
     * List all users
     *
     * @param array $params
     *
     * @throws ResponseException
     * @throws \Exception
     * @return mixed
     */
    public function findAll(array $params = [])
    {
        if (isset($params['organization_id'])) {
            $this->endpoint = "organizations/{$params['organization_id']}/users.json";
        } elseif (isset($params['group_id'])) {
            $this->endpoint = 'groups/' . $params['group_id'] . '/users.json';
        } else {
            $this->endpoint = 'users.json';
        }

        return $this->traitFindAll();
    }

should be fixed to:

    /**
     * List all users
     *
     * @param array $params
     *
     * @throws ResponseException
     * @throws \Exception
     * @return mixed
     */
    public function findAll(array $params = [])
    {
        if (isset($params['organization_id'])) {
            $this->endpoint = "organizations/{$params['organization_id']}/users.json";
        } elseif (isset($params['group_id'])) {
            $this->endpoint = 'groups/' . $params['group_id'] . '/users.json';
        } else {
            $this->endpoint = 'users.json';
        }

        return $this->traitFindAll($params);
    }

The only change is missing parameter $params in the line:
return $this->traitFindAll();

$tickets = $client->tickets()->findAll();

Very simply not problem with autoload or authentication.

Just trying to get all tickets:

$tickets = $client->tickets()->findAll();
print_r($tickets);

Produces:
PHP Fatal error: Call to a member function getReasonPhrase() on a non-object in /var/www/html/ZD/vendor/zendesk/zendesk_api_client_php/src/Zendesk/API/Exceptions/ApiResponseException.php on line 22

I tried to follow some of the previous reports of similar challenges and I wan unable to find an answer.

Can you provide some insight into what I am doing incorrectly?

open_basedir & CURLOPT_FOLLOWLOCATION

If open_basedir is set, PHP issues a warning,

PHP Warning:  curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set in [...]/zendesk_api_client_php/src/Zendesk/API/Http.php on line 110

Add requester name & email to tickets()->create

Hello,

Is it possible to have the requester name & email when submitting a new ticket?

I have a simple contact form email / message and I get the name in session.

The following code works perfectly (comes from your sample):

$newTicket = $client->tickets()->create(array(
    'subject' => 'test subject',
    'comment' => array (
         'body' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
    ),
    'priority' => 'normal'
));

How can I add the customer name as requester? Because currently, on Zendesk, the requester is me ($username)

  • I have tried to add 'name', 'email', 'requester' to the array but same result

I have a working version with curl method, but experiencing some "self signed certificate" problems on my local machine. So, this is just to know if I can do that with the API client ๐Ÿ˜ƒ

Thanks!

Importing tickets fails when importing a ticket with multiple comments

Importing tickets fails when importing a ticket with multiple comments. Annoyingly the error message is so generic. The error in the end was the author ID was not valid.

I'm assuming that the first comment has a fall back in the code to use the requester_id whereas the subsequent comments do not have a fall back as the comment could be from anyone.

Zendesk Voice API support

There seems to be no access to the Zendesk Voice API. I am looking for a way to create voice tickets. Can it be done with this client? If yes, how? And if not, what would be the best practice with PHP.

Error completing request [url] https://betalabs.zendesk.com/api/v2/tickets.json [http method] GET

When I utilize the method "tickets()->findAll()" exactly like the example in readme, this exception returns:

Error completing request [url] https://betalabs.zendesk.com/api/v2/tickets.json [http method] GET

My code sample:
$zendesk = new ZendeskAPI($subdominio, $usuario);
$zendesk->setAuth('basic', ['username' => $usuario, 'token' => $senha]);

$tickets = $zendesk->tickets()->findAll();

When I try authenticate with HTTP configurations (with Scheme = "HTTP" AND Port = "80") (because I was making test in my local environment), this exception returns:

Client error response [url] http://betalabs.zendesk.com/api/v2/tickets/recent.json [http method] GET [status code] 400 [reason phrase] Bad Request [details] This is an HTTPS only API

How to proceed?

Waiting for answers,
Victor

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.