curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
        //            curl_setopt($ch, CURLOPT_POSTFIELDS, '{"sport":"football","outcomeId":"155666431"}');
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('AppId: ' . $this->appId, 'Authorization: 8fa8f25310b05400938cc84ae5353ce2871882b02b236e929fab84fc73c4413e'));
        // Execute
        $result = curl_exec($ch);
        curl_close($ch);
        //return a asociative array
        return json_decode($result, true);
    }
    public function doSomethingWithThat()
    {
        $json = $this->curlMagic();
        if (is_array($json)) {
            $array = array();
            foreach ($json['tips'] as $tip) {
                $array[] = $tip['sport'];
                $array[$tip['sport']] = $tip['vc_outcome_id'];
            }
            $output = $array;
        } else {
            $output = 'We don\'t keep data for this source.';
        }
        return $output;
        return $json;
    }
}
$call = new CallForTips();
echo '<pre>';
print_r($call->curlMagic());
echo '</pre>';
Exemplo n.º 2
0
        //build URL
        $url = self::$api_url . "?source=" . self::$source;
        //  CURL
        $ch = curl_init();
        // Disable SSL verification
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        // Will return the response, if false it print the response
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        // Set the url
        curl_setopt($ch, CURLOPT_URL, $url);
        // Execute
        $result = curl_exec($ch);
        // Closing
        curl_close($ch);
        //return a asociative array
        return json_decode($result, true);
    }
}
$call = new CallForTips('');
echo '<pre>';
var_dump($call->checkTips());
echo '</pre>';
date_default_timezone_set('Europe/London');
echo strtotime('2016-01-03 19:30:00');
echo '<hr />';
echo '<p style="color: #BADA55;">1451849400</p>';
//  foreach ($call->checkTips() as $k => $v) {
//	if ($v < 10) {
//	  trigger_error("$k has only $v tips", E_USER_NOTICE);
//	}
//  }