1

我使用这个例子在 php 中创建了一个 oauth api

http://code.google.com/p/oauth-php/wiki/ConsumerHowTo#OAuth_Consumer

在消费者页面中,我将参数作为 json 编码字符串传递。

$key = '35345345345vertrtertert'; // fill with your public key 
$secret = 'h rtyrtyr767567567567'; // fill with your secret key
$url = "www.server.com/serverurl.php"; 

$options = array('consumer_key' => $key, 'consumer_secret' => $secret);
OAuthStore::instance("2Leg", $options);

$method = "POST";
$params = array(
           'radius' => '50',
           'latitude'=>'13.35',
           'longitude'=>'17.35'
     );
$params = json_encode($params);

并在服务器页面(即 serverurl.php)中使用打印请求

print_r($_REQUEST);

我使用 json decode 解码了字符串,但我得到这个值

    Array
(
    [radius] => 50
    [latitude] => 13_35
    [longitude] => 17_35
)

被纬度和经度.替换_我如何管理这个

4

1 回答 1

1

似乎在您的编码/解码过程中的某处,该值正试图被解析为一些东西。如果您真的想将这些值作为数字使用,则不应在数组中将它们设置为字符串。尝试这个

$params = array(
    'radius' => 50,
    'latitude'=> 13.35,
    'longitude'=> 17.35
);

请注意,我已经删除了数字周围的引号,因此它们将在编码过程中被视为数字。

于 2012-08-03T14:22:33.520 回答