Skip to content

Commit

Permalink
improved to use curl and not cache connections
Browse files Browse the repository at this point in the history
  • Loading branch information
Bastian Lüttig committed Mar 28, 2019
1 parent c07cba6 commit 78ffd24
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions generic/cuneros_api.class.inc.php
Expand Up @@ -277,8 +277,22 @@ protected function build_params($src, $dst, $action, $amount, $subject, $own_id)
}
protected function server_request($server, $action_url, $data) {
$string = $server . $action_url . "?" . $data;
$fp = file_get_contents($string);
return json_decode($fp);
$ch = curl_init();

curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // return response as a string
curl_setopt($ch, CURLOPT_URL, $string); // the URL
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE); // verify SSL info
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE); // make sure, connection is new

// Get JSON
$result = curl_exec($ch);
$content = FALSE;
// Basic error handling
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) === 200) {
$content = json_decode($result, FALSE);
}
curl_close($ch);
return $content;
}
protected function request($src, $dst, $action, $amount, $subject, $own_id) {
$action_url = 'access/';
Expand Down

0 comments on commit 78ffd24

Please sign in to comment.