Giter Site home page Giter Site logo

Comments (7)

rearley avatar rearley commented on August 27, 2024

Do you have a 'use' statement anywhere? Add the follow:

use Zendesk\API\Client as Zendesk;
$zendesk = new Zendesk($apiKey, $user, $subDomain, $suffix = '.json', $test = false);

or change your code from:

$zendesk = new Zendesk($apiKey, $user, $subDomain, $suffix = '.json', $test = false);

to:

$zendesk = new Zendesk\API\Client($apiKey, $user, $subDomain, $suffix = '.json', $test = false);

What is in your zendesk.php file? Are you using any autoloading?

from zendesk_api_client_php.

kenwalker08 avatar kenwalker08 commented on August 27, 2024

Thanks rearley for reply.

I have added the "use" statement as you mentioned but now it is throwing following error:

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

here is the updated code.

"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"; ?>

Also i have the following code in zendesk.php file:

api_key = $apiKey; $this->user = $user; $this->base = 'https://' . $subDomain . '.zendesk.com/api/v2'; $this->suffix = $suffix; if ($test === true && !$this->test()) { throw new Exception('Cannot connect or authentice with the Zendesk API'); } } ``` public function call($url, $json, $action) { if (substr_count($url, $this->suffix) == 0) { $url .= '.json'; } $ch = curl_init(); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_MAXREDIRS, 10 ); curl_setopt($ch, CURLOPT_URL, $this->base.$url); curl_setopt($ch, CURLOPT_USERPWD, $this->user."/token:".$this->api_key); switch($action){ case "POST": curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); break; case "GET": curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); break; case "PUT": curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); default: break; } curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json')); curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $output = curl_exec($ch); curl_close($ch); $decoded = json_decode($output); return is_null($decoded) ? $output : $decoded; } public function test() { return $this->call('/tickets', '', 'GET'); } ``` }

from zendesk_api_client_php.

rearley avatar rearley commented on August 27, 2024

Ok I think I am lost on what you are trying to do. Are you using the library in this GIT REPO or are you trying to call the API yourself ( which is what it looks like in your code ). If you are trying to call the API yourself and are having issues then you might want to go to support.zendesk.com for this problems.

The issue system here is for the client library in this REPO which does not appear to be what you are using.

from zendesk_api_client_php.

kenwalker08 avatar kenwalker08 commented on August 27, 2024

I am using the same API that GitHub Provides. May you give me a sample code (in zip) which indicates how to create a ticket on zendesk? It would be really appreciable. Thanks for your cooperation.

from zendesk_api_client_php.

rearley avatar rearley commented on August 27, 2024

How are you installing the code from here? Are you using composer or did you just download the code? This will help with any example someone can give you.

from zendesk_api_client_php.

dpawluk avatar dpawluk commented on August 27, 2024

@kenwalker08, please let me know if you still need any help. If not I'll go ahead and close this issue soon.

from zendesk_api_client_php.

kladskull avatar kladskull commented on August 27, 2024

Same issue here, installed via Composer...

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.