Giter Site home page Giter Site logo

Comments (9)

RaFeNiX avatar RaFeNiX commented on July 24, 2024

Hi Rafael, try created_at>2015-01-01

Em 26/10/2015 10:50, Rafael Foster [email protected] escreveu:
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-06"]);

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

I appreciate that!


Reply to this email directly or view it on GitHub:
#217

from zendesk_api_client_php.

rafaelfoster avatar rafaelfoster commented on July 24, 2024

I've done this befere without success.
The organization field is being filtered perfectly, but creation date doesn't.

If try this codes bellow:

$tickets = $zendesk->tickets()->findAll(["created_at" => "2015-01-07", "organization_id" => $orgID]);

and

$tickets = $zendesk->tickets()->findAll(["created_at>2015-01-07", "organization_id" => $orgID]);

also

$tickets = $zendesk->tickets()->findAll(["created_at>2015-01-07"]);

print_r($tickets);
....

It returns me all tickets, like:
[created_at] => 2015-06-03T13:52:39Z
[updated_at] => 2015-07-17T20:05:29Z
[type] => problem
[subject] => "loren ipson"
etc....

Any idea?

from zendesk_api_client_php.

RaFeNiX avatar RaFeNiX commented on July 24, 2024

Hi rafael,
i just figured out you're using the findAll() from tickets().In this case i would use ## $teste = $client->search(['query'=>"type:ticket created_at>2015-01-07"]); ##
try it, working here

Date: Mon, 26 Oct 2015 08:23:05 -0700
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: [zendesk_api_client_php] Filter and search request (#217)

I've done this befere without success.

The organization field is being filtered perfectly, but creation date doesn't.

If try this codes bellow:

$tickets = $zendesk->tickets()->findAll(["created_at" => "2015-01-07", "organization_id" => $orgID]);

and

$tickets = $zendesk->tickets()->findAll(["created_at>2015-01-07", "organization_id" => $orgID]);

also

$tickets = $zendesk->tickets()->findAll(["created_at>2015-01-07"]);

print_r($tickets);

....

It returns me all tickets, like:

[created_at] => 2015-06-03T13:52:39Z

[updated_at] => 2015-07-17T20:05:29Z

[type] => problem

[subject] => "loren ipson"

etc....

Any idea?


Reply to this email directly or view it on GitHub.

from zendesk_api_client_php.

rafaelfoster avatar rafaelfoster commented on July 24, 2024

Thanks for your response @RaFeNiX

Unfortunally, it still not working.

I've copied your entire line and add it to my code.
The API doesn't returns me any erros.

But it return this:

Zendesk\API\Resources\Core\Search Object
(
[resourceName:protected] => search
[objectName:protected] => search
[objectNamePlural:protected] => searches
[client:protected] => Zendesk\API\HttpClient Object
(
[auth:protected] => Zendesk\API\Utilities\Auth Object
(
[authStrategy:protected] => basic
[authOptions:protected] => Array
(
[username] => [email protected]
[token] => 8Gasdsadsada4GCBAuRiRLitJCcj6wbHNLWPQEhhTcl3epIfWK
)

            )

        [subdomain:protected] => EXAMPLE
        [username:protected] => [email protected]
        [scheme:protected] => https
        [hostname:protected] => zendesk.com
        [port:protected] => 443
        [apiUrl:protected] => https://EXAMPLE.zendesk.com:443/api/v2/
        [apiVer:protected] => v2
        [sideload:protected] => 
        [debug:protected] => Zendesk\API\Debug Object
            (
                [lastRequestBody] => 
                [lastRequestHeaders] => Array
                    (
                        [Host] => Array
                            (
                                [0] => EXAMPLE.zendesk.com
                            )

                        [Accept] => Array
                            (
                                [0] => application/json
                            )

                        [Content-Type] => Array
                            (
                                [0] => application/json
                            )

                        [User-Agent] => Array
                            (
                                [0] => ZendeskAPI PHP 2.0.0
                            )

                    )

                [lastResponseCode] => 200
                [lastResponseHeaders] => Array
                    (
                        [Server] => Array
                            (
                                [0] => nginx
                            )

                        [Date] => Array
                            (
                                [0] => Mon, 26 Oct 2015 16:28:05 GMT
                            )

                        [Content-Type] => Array
                            (
                                [0] => application/json; charset=UTF-8
                            )

                        [Content-Length] => Array
                            (
                                [0] => 5349
                            )

                        [Connection] => Array
                            (
                                [0] => keep-alive
                            )

                        [Status] => Array
                            (
                                [0] => 200 OK
                            )

                        [X-Zendesk-API-Version] => Array
                            (
                                [0] => v2
                            )

                        [X-Frame-Options] => Array
                            (
                                [0] => SAMEORIGIN
                            )

                        [Strict-Transport-Security] => Array
                            (
                                [0] => max-age=31536000;
                            )

                        [X-UA-Compatible] => Array
                            (
                                [0] => IE=Edge,chrome=1
                            )

                        [ETag] => Array
                            (
                                [0] => W/"46af5d3faec10f397298da25788aa75f"
                            )

                        [Cache-Control] => Array
                            (
                                [0] => must-revalidate, private, max-age=0
                            )

                        [X-Zendesk-Origin-Server] => Array
                            (
                                [0] => app13.pod4.sac1.zdsys.com
                            )

                        [X-Request-Id] => Array
                            (
                                [0] => 099b76e0-c9d2-4b66-cb0a-b8ca3a61dd58
                            )

                        [X-Runtime] => Array
                            (
                                [0] => 0.699089
                            )

                        [X-Rack-Cache] => Array
                            (
                                [0] => miss
                            )

                        [X-Zendesk-Request-Id] => Array
                            (
                                [0] => b23edeab94d1ca72b9c912adas
                            )

                        [X-Content-Type-Options] => Array
                            (
                                [0] => nosniff
                            )

                    )

                [lastResponseError] => 
            )

        [guzzle] => GuzzleHttp\Client Object
            (
                [config:GuzzleHttp\Client:private] => Array
                    (
                        [handler] => GuzzleHttp\HandlerStack Object
                            (
                                [handler:GuzzleHttp\HandlerStack:private] => Closure Object
                                    (
                                        [static] => Array
                                            (
                                                [default] => Closure Object
                                                    (
                                                        [static] => Array
                                                            (
                                                                [default] => GuzzleHttp\Handler\CurlMultiHandler Object
                                                                    (
                                                                        [factory:GuzzleHttp\Handler\CurlMultiHandler:private] => GuzzleHttp\Handler\CurlFactory Object
                                                                            (
                                                                                [handles:GuzzleHttp\Handler\CurlFactory:private] => Array
                                                                                    (
                                                                                        [0] => Resource id #90
                                                                                    )

                                                                                [maxHandles:GuzzleHttp\Handler\CurlFactory:private] => 50
                                                                            )

                                                                        [selectTimeout:GuzzleHttp\Handler\CurlMultiHandler:private] => 1
                                                                        [active:GuzzleHttp\Handler\CurlMultiHandler:private] => 0
                                                                        [handles:GuzzleHttp\Handler\CurlMultiHandler:private] => Array
                                                                            (
                                                                            )

                                                                        [delays:GuzzleHttp\Handler\CurlMultiHandler:private] => Array
                                                                            (
                                                                            )

                                                                        [_mh] => Resource id #93
                                                                    )

                                                                [sync] => GuzzleHttp\Handler\CurlHandler Object
                                                                    (
                                                                        [factory:GuzzleHttp\Handler\CurlHandler:private] => GuzzleHttp\Handler\CurlFactory Object
                                                                            (
                                                                                [handles:GuzzleHttp\Handler\CurlFactory:private] => 
                                                                                [maxHandles:GuzzleHttp\Handler\CurlFactory:private] => 3
                                                                            )

                                                                    )

                                                            )

                                                        [parameter] => Array
                                                            (
                                                                [$request] => 
                                                                [$options] => 
                                                            )

                                                    )

                                                [streaming] => GuzzleHttp\Handler\StreamHandler Object
                                                    (
                                                        [lastHeaders:GuzzleHttp\Handler\StreamHandler:private] => Array
                                                            (
                                                            )

                                                    )

                                            )

                                        [parameter] => Array
                                            (
                                                [$request] => 
                                                [$options] => 
                                            )

                                    )

                                [stack:GuzzleHttp\HandlerStack:private] => Array
                                    (
                                        [0] => Array
                                            (
                                                [0] => Closure Object
                                                    (
                                                        [parameter] => Array
                                                            (
                                                                [$handler] => 
                                                            )

                                                    )

                                                [1] => http_errors
                                            )

                                        [1] => Array
                                            (
                                                [0] => Closure Object
                                                    (
                                                        [parameter] => Array
                                                            (
                                                                [$handler] => 
                                                            )

                                                    )

                                                [1] => allow_redirects
                                            )

                                        [2] => Array
                                            (
                                                [0] => Closure Object
                                                    (
                                                        [parameter] => Array
                                                            (
                                                                [$handler] => 
                                                            )

                                                    )

                                                [1] => cookies
                                            )

                                        [3] => Array
                                            (
                                                [0] => Closure Object
                                                    (
                                                        [parameter] => Array
                                                            (
                                                                [$handler] => 
                                                            )

                                                    )

                                                [1] => prepare_body
                                            )

                                    )

from zendesk_api_client_php.

RaFeNiX avatar RaFeNiX commented on July 24, 2024

try this simple code.

include("./vendor/autoload.php");
use Zendesk\API\Client as ZendeskAPI;
$subdomain = "";
$username = "";
$token = "";
$client = new ZendeskAPI($subdomain, $username);
$client->setAuth('token', $token);

$tesrte = $client->search(['query'=>"type:ticket created_at>2015-10-20"]);

echo json_encode($tesrte);

from zendesk_api_client_php.

rafaelfoster avatar rafaelfoster commented on July 24, 2024

The json returns me empty.

Hey, maybe it could be the last version of API?
I've cloned this repo.
Which version are you using?

error_zenapi

error_zenapi2

from zendesk_api_client_php.

miogalang avatar miogalang commented on July 24, 2024

Hi @rafaelfoster

On version 2 of the client things have changed quite a bit.

To achieve what you want, you would want a snippet like

$response = $client->search()->find('type:ticket created>=2015-09-01 created<2015-10-01');

Search is now a resource you can make calls on, similar to a ticket or a user. We wanted to keep this pattern consistent.

There definitely should be an example on search, will put that in the list of things to do.

For more documentation on using search there is https://developer.zendesk.com/rest_api/docs/core/search and https://support.zendesk.com/hc/en-us/articles/203663226

And a pro tip to test your query string easily is to try it out in the zendesk ui.
screen shot 2015-10-28 at 10 20 54 am

It also seems like you are using the version 1 way of making a search, if you are upgrading, there is a handy upgrade guide that can help you upgrade.

Please let me know if this works.

from zendesk_api_client_php.

rafaelfoster avatar rafaelfoster commented on July 24, 2024

Yeah! That's working now @miogalang

I really appreciate that!

Thanks for your help too @RaFeNiX

from zendesk_api_client_php.

JohnieMutio avatar JohnieMutio commented on July 24, 2024

Hey, am using php curl to execute my search query but It returns null everytime. Below is a snippet of my code:

$date="2018-09-01";
//$link = isset($link) ? $link : "https://$subdomain.zendesk.com/api/v2/$resource.json?created_at>=".$date;
$link = isset($link) ? $link : "https://$subdomain.zendesk.com/api/v2/search?query=type:user created_at=".$date;
while($link){
$ch = curl_init($link);

			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

			curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false); 
										
			curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

			curl_setopt($ch, CURLOPT_USERPWD, $email . ":" .$password);

			$response = curl_exec($ch);

			$output = json_decode($response);
				
			var_dump($output);

$link = $output->next_page;
}

What am I doing wrong?

from zendesk_api_client_php.

Related Issues (20)

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.