1
사용자 장소 데이터 (사용자 체크인 정보의 장소에 대한 세부 정보)를 가져 오려고합니다. 사용자 액세스 토큰을 사용하여 데이터를 가져 왔습니다. 이것은 내가 사용하고있는 코드입니다 :foursquare/user/self/checkins 데이터에서 장소 분석하기
if($_GET['code']){
$authkey = file_get_contents("https://foursquare.com/oauth2/access_token? client_id=".$client_id."&client_secret=".$secret."&grant_type=authorization_code&redirect_uri=".$redirect."&code=".$_GET['code']);
$decoded_auth = json_decode($authkey,true);
$venueinfo = file_get_contents("https://api.foursquare.com/v2/users/self/checkins?oauth_token=$access_token&v=$version");
$decoded_venueinfo = json_decode($venueinfo, true);
foreach ($decoded_venueinfo->response->checkins->items->venue as $result){
echo $result->name;
echo $result->id;
echo $result->location->address;
echo $result->location->city;
echo $result->location->country;
}
}
빈 페이지가 나타납니다. 에코 "오류"와 함께 첫 번째 "if"의 끝에 "else"를 추가하려고 시도했습니다. 그래서 "if"문 조건이 거짓이라고 추측합니다. 저는 PHP를 처음 접했고 배우로서 배웁니다. 어떤 도움을 주시면 감사하겠습니다.
감사합니다. 이제 파싱 문제가 있습니다. 사용자가 체크인 한 장소를 표시하려고합니다. 이것은 코드입니다 : $ decoded_venueinfo = json_decode ($ venueinfo, true); foreach ($ decoded_venueinfo-> response-> checkins-items-venue를 $ 장소로 사용) { $ name = $ venue-> name; \t $ id = $ venue-> id; echo "장소 이름 : $ name, Id : $ id"; } 작동하지 않습니다. 화면에 "어레이"가 인쇄됩니다. – user1889653