I'm new to CiViCRM. I want to fetch events which are created in CiViCRM which is hosted on another server. So basically I want to fetch CiViCRM data from one individual site to my site. I don't know that which are the ways to do it and which is the best one. But I think Rest option would be good if I'm not wrong. I'm not able to find any similar example which is near to my task. All I don't understand that how should I use my rest url with code:
1) Option 1:
$api = new civicrm_api3(array ('server' => 'http://localhost/abc',
'api_key'=>'123456789', 'key'=>'123xyzABC'));
2) Option 2:
$contactxml = simplexml_load_file("http://localhost/abc/sites/all/modules/civicrm/extern /rest.php?entity=contact&action=get&key=<site key>&api_key=$apikey&last_name=Koot");
foreach ($contactxml->children() as $contact) {
$display = $contact->display_name;
}
Is there any other options. I want to go for option 1 if that is possible. How to get response in JSON?
Any help would be appreciated.
Thanks