Comments (7)
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.
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.
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.
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.
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.
@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.
Same issue here, installed via Composer...
from zendesk_api_client_php.
Related Issues (20)
- PHP8 Error: array_merge() does not accept unknown named parameters HOT 1
- php 5.6 Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE) in /var/www/clients/client1/web6/web/vendor/guzzlehttp/guzzle/src/HandlerStack.php on line 47 HOT 1
- Update Packagist with the new version HOT 3
- Unmerged PRs HOT 3
- Okta HOT 2
- Oktane22
- Add comment to ticket HOT 3
- FindAll method Ambiguity in Error Webhooks HOT 3
- No events API support? HOT 2
- Type error: Argument 1 passed to GuzzleHttp\Client::send()
- Allow any PSR-17 and PSR-18 implementation to be used
- How to get the latest tickets created by a customer? HOT 2
- webhook count support not available ? HOT 1
- Repository maintenance status HOT 14
- Problem with updates of users HOT 2
- tickets createMany method implementation HOT 2
- No method called iterator available in Zendesk\API\Resources\Core\Tickets HOT 2
- Testing Slack notification HOT 3
- Test Issue HOT 3
- Another test HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zendesk_api_client_php.