0
votes

I'm trying to get data from a system through its own API. It's this one: https://www.zoho.com/recruit/get-records.html

So I'm really new to PHP, and all I can find is examples where they grab the variable name from the URL via the get method. Or with this API in particular, inserting data.

I'm trying to put the data from the request into an array, but all I get from the print is Array(). Am I going about this totally wrong? The API explains it really awfully, I think... and there's no example anywhere.

$url = "https://recruit.zoho.com/ats/private/xml/JobOpenings/getRecords?apikey=$api_key&ticket=$ticket_id";

$request = new WP_Http;
$result = $request->request($url, $data = array());
print_r($data);
2
Don't you want to print $result instead of $data?user3849602
Haha, yes. That got me somewhere! Now my ticket is invalid, looking into it, thanksRasmus
It seems I get an internal server error 500 now. Looking into it.Rasmus

2 Answers

1
votes

Besides printing $data instead of $result there was nothing wrong. I contacted the company that hosts the data, and it was an issue on their end.

0
votes

Try this code...

        $url = "https://recruit.zoho.com/ats/private/xml/JobOpenings/getRecords?apikey=$api_key&ticket=$ticket_id";
        $headers = "Content-Type: application/x-www-form-urlencoded \n  accesskey: abcdefghijklmnopqrstuvwx \n  outputtype: json";//or what ever is your content type);

        $request = new WP_Http;
        $result = $request->request( $url, array('headers' => $headers) );

        if ( !is_wp_error($result) ) {$body = json_decode($result, true);}