/[openfoncier]/trunk/services/curlsendrest.php
ViewVC logotype

Contents of /trunk/services/curlsendrest.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 540 - (show annotations)
Fri Oct 26 15:45:51 2012 UTC (12 years, 3 months ago) by mlimic
File size: 1415 byte(s)
implementation of the php script that does the update done; cron call and email sending done; remaining: change messages from English to French, test on real instance of openfoncier
1 <?php
2
3
4 class CurlSendREST {
5
6
7 public function __construct() {
8 //
9 }
10
11 public function __destruct() {
12 //
13 }
14
15 public function curlPost($url, $data) {
16 $data_string = json_encode($data);
17
18 $ch = curl_init($url);
19 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
20 curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
21 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
22 curl_setopt($ch, CURLOPT_HTTPHEADER, array(
23 'Content-Type: application/json',
24 'Content-Length: ' . strlen($data_string))
25 );
26 $ret = curl_exec($ch);
27 if ($ret === false) {
28 $ret = "\"curlerror\" : ".curl_error($ch);
29 }
30 curl_close($ch);
31 return $ret;
32 }
33 }
34
35 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26