PHP   发布时间:2022-04-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了php-使用API​​获取Gowalla签入历史大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

我一直在使用Gowalla API,并且想知道是否有人找到一种方法获取所有最近签入的列表(只是您自己的,不包括朋友).该文档非常糟糕.

解决方法:

您可以使用他们的API Explorer查看可用的API.它非常简洁,可以用作很好的文档,只需查看REST样式的URL即可.

这是获取最后5个签到的基本代码.您将需要一个API密钥.

$username = 'sco';
$api_key = 'f6cd524ac9c4413abfb41d7123757d9';
$checkin_num = 5;
$url = "http://api.gowalla.com/users/{$usernamE}/stamps?limit={$checkin_num}";

// setup curl
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_httpHEADER, array (
    "Accept: application/json",
    "X-Gowalla-API-Key: {$api_key}",
));
$body = curl_exec($ch);
curl_close($ch);
$json = json_decode($body, truE);
foreach($json['stamps'] as $stamp) {
    print $stamp['spot']['name'] . '<br/>';
    print "<pre>";
    print_r($stamp);
    print "</pre>";
}

这是一个签入“ stamp”对象的样子:

Array
(
    [spot] => Array
        (
            [image_url] => http://static.gowalla.com/categories/24-standard.png
            [url] => /spots/19890
            [lat] => 38.9989524833
            [address] => Array
                (
                    [locality] => Kansas City
                    [region] => MO
                )

            [lng] => -94.5939345333
            [name] => The GAF Pub & Grille
        )

    [first_checkin_at] => 2010-06-12T19:16:57+00:00
    [checkins_count] => 1
    [last_checkin_at] => 2010-06-12T19:16:57+00:00
)

大佬总结

以上是大佬教程为你收集整理的php-使用API​​获取Gowalla签入历史全部内容,希望文章能够帮你解决php-使用API​​获取Gowalla签入历史所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: