Скриптик

Discussion in 'PHP' started by Henky, 15 Oct 2009.

  1. Henky

    Henky Banned

    Joined:
    9 Oct 2009
    Messages:
    0
    Likes Received:
    12
    Reputations:
    0
    Code:
    <?
    function get_app_balance($api_id, $api_secret){
    	$request = Array();
    	$request[] = "api_id=$api_id";
    	$request[] = "method=secure.getAppBalance";
    	$request[] = "timestamp=" . (time() + 172814);
    	$request[] = "random=" . rand(1000, 100000);
    	$request[] = "v=2.0";
    
    	array_multisort($request);
    
    	$sig = "";
    	foreach ($request as $r){
    		$sig .= $r;
    	}
    
    	$sig .= $api_secret;
    	$sig = md5($sig);
    
    	$request[] = "sig=$sig";
    
    	$req = "";
    
    	foreach ($request as $r){
    		$req .= "$r&";
    	}
    
    
    	$result = file_get_contents("http://api.vkontakte.ru/api.php?$req");
    	file_put_contents("log.txt", "$result\r\n\r\n", 6666);
    	preg_match('/<balance>(.*?)<\/balance>/', $result, $out);
    	return (int)$out[1];
    }
    
    function get_user_balance($app_id, $api_secret, $uid){
    	$request = Array();
    	$request[] = "api_id=$app_id";
    	$request[] = "method=secure.getBalance";
    	$request[] = "timestamp=" . (time() + 172814);
    	$request[] = "random=" . rand(1000, 100000);
    	$request[] = "v=2.0";
    	$request[] = "uid=$uid";
    	
    
    	array_multisort($request);
    
    	$sig = "";
    	foreach ($request as $r){
    		$sig .= $r;
    	}
    
    	$sig .= $api_secret;
    	$sig = md5($sig);
    
    	$request[] = "sig=$sig";
    
    	$req = "";
    
    	foreach ($request as $r){
    		$req .= "$r&";
    	}
    
    
    	$result = file_get_contents("http://api.vkontakte.ru/api.php?$req");
    	file_put_contents("log.txt", "$result\r\n\r\n", 6666);
    	preg_match('/<balance>(.*?)<\/balance>/', $result, $out);
    	return (int)$out[1];
    }
    вот скрипт с сервера приложения.. кто поможет что тут нетак.. неотображаеться баланс в приложении
     
  2. BlindSide

    BlindSide Banned

    Joined:
    15 Oct 2009
    Messages:
    0
    Likes Received:
    4
    Reputations:
    0
    Помогите тоже с этим проблемы!
     
  3. .::BARS::.

    .::BARS::. Elder - Старейшина

    Joined:
    13 Oct 2007
    Messages:
    379
    Likes Received:
    45
    Reputations:
    10
    $out что возвращяет?
     
    2 people like this.
  4. Henky

    Henky Banned

    Joined:
    9 Oct 2009
    Messages:
    0
    Likes Received:
    12
    Reputations:
    0
    не знаю.. ;)