Example #1
0
if ($plan_id != FALSE) {
    $xml .= '<plan_id>' . $plan_id . '</plan_id>';
}
if ($amount != FALSE) {
    $xml .= '<amount>' . $amount . '</amount>';
}
$xml .= '</request>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
$data = curl_exec($ch);
$response = convert_to_array($data);
echo convert_to_json($response);
function convert_to_json($arr)
{
    if (function_exists('json_encode')) {
        return json_encode($arr);
    }
    //Lastest versions of PHP already has this functionality.
    $parts = array();
    $is_list = false;
    //Find out if the given array is a numerical array
    $keys = array_keys($arr);
    $max_length = count($arr) - 1;
    if ($keys[0] == 0 and $keys[$max_length] == $max_length) {
        //See if the first key is 0 and last key is length - 1
        $is_list = true;
        for ($i = 0; $i < count($keys); $i++) {
Example #2
0
// if(isset($_GET))
// {
//     foreach($_GET as $key =>$value)
//     {
//         $values .= "'$value',";
//     }
//     $values .= "'$file_name'";
// }
// // generate query of parametres and image name
// $query ="INSERT INTO $dbtable VALUES ('',$values)";
// // write data to db
//  $result1 = db_query($dbuser, $dbpass, $dbname, $query);
//  $img_url = convert_to_json($img_url);
$result = (array) json_decode($img_url);
$result[0]->limage = 'http://ru.konfischerator.de/' . $result[0]->limage;
$x = convert_to_json($result);
print_r($x);
// echo $img_url;
// functions
function get_img($url)
{
    $result = file_get_contents($url);
    // $x = explode(',', $result);
    // $str = $x[29];
    // $cuttedstr = substr($str, 22, 20);
    // $cuttedstr = substr($cuttedstr, 0, -1);
    // $img_src = "http://ru.konfischerator.de/temp/p.jpg?$cuttedstr";
    return $result;
}
function folder_exists($folder)
{