-3

I am trying to access data in Zoho Books using PHP and SQL, but I do not know the first step. I understand PHP and SQL, but need assistance in how to retrieve Zoho's data. Any assistance would be greatly appreciated.

I have done a fair amount of research into Zoho, but I keep getting informed there is need of an API to access this data. Information on the API leads to the need to use cURL, which appears to require Composer. How all of this is supposed to fit together is still not clear in my mind. Could anyone with more experience kindly show how this all works?

Ideally I would like to be able to query Zoho and be able to withdraw whichever records meet my criteria. This is the key I am missing. I already know the code necessary to manipulate the data and upload it into MySQL.

Edit: I have composer installed, but it seems unable to locate any versions of cURL newer than 1.7.

I know how to get a key to access Zoho through the backend. I am simply missing the syntax to implement.

EG, where would the following call be implemented:

$ curl https://books.zoho.com/api/v3/organizations?organization_id=10234695 -H 'Authorization: Zoho-authtoken {secret token}'

maiorano84
  • 11,574
  • 3
  • 35
  • 48
JTB
  • 3
  • 3
  • 1
    cURL itself does not necessitate the use of Composer. Having a working knowledge of [Composer](https://getcomposer.org/), however, will make your life much easier. In order to effectively work with APIs in PHP, you will either need to understand how to use [cURL natively in PHP](http://php.net/manual/en/book.curl.php), or use a proper HTTP Client library like [Guzzle](http://docs.guzzlephp.org/en/stable/). But as it stands, your question is far too broad for anyone here to help you. – maiorano84 Jan 17 '19 at 21:46
  • Please note edit – JTB Jan 17 '19 at 21:53
  • 1
    https://incarnate.github.io/curl-to-php/ will convert your posted curl command to the correct PHP functions – WOUNDEDStevenJones Jan 17 '19 at 22:09

1 Answers1

0

From https://incarnate.github.io/curl-to-php/, if you paste in:

curl https://books.zoho.com/api/v3/organizations?organization_id=10234695 -H 'Authorization: Zoho-authtoken {secret token}'

Output PHP (obviously replace {secret token}):

// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://books.zoho.com/api/v3/organizations?organization_id=10234695');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');


$headers = array();
$headers[] = 'Authorization: Zoho-authtoken {secret token}';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
WOUNDEDStevenJones
  • 5,150
  • 6
  • 41
  • 53