현재 Foursquare API를 사용하고 있습니다. 다음 PHP 스크립트를 실행할 때마다 사용자 프로필에 표시된 최신 체크 인을 가져 와서 텍스트 파일에 씁니다. 텍스트 파일의 각 항목은 쉼표로 구분됩니다.데이터 쓰기 및 중복 무시.
내 문제는 PHP 파일을 5 번 실행할 수 있고 이미 가져온 동일한 체크 인을 가져 오는 것입니다. 내가 무엇을하고 싶습니다 아래의 PHP 스크립트는 foursquare JSON에 표시되는 사용자의 가장 최근 체크인을 읽습니다. 그리고이 항목 앞에 텍스트 파일에 이미 집계 된 내용이 있다면, 그것을 무시하고 텍스트 파일에 추가하지 않습니다.
<?php
$charlotte = json_decode(file_get_contents("https://api.foursquare.com/v2/users/5464313?oauth_token=2ZO1PQOUAD5SXRAJOLZVH53RBQ1EB2C23FE2GUZLJYQUJ3SY&v=20121123"));
$venuename = $charlotte->response->user->checkins->items[0]->venue->name;
$file = 'charlotte.txt';
$current = file_get_contents($file);
$current .= $venuename.',';
file_put_contents($file, $current);
?>
<?php
$arran = json_decode(file_get_contents("https://api.foursquare.com/v2/users/1050511?oauth_token=2ZO1PQOUAD5SXRAJOLZVH53RBQ1EB2C23FE2GUZLJYQUJ3SY&v=20121109"));
$venuename = $arran->response->user->checkins->items[0]->venue->name;
$file = 'arran.txt';
$current = file_get_contents($file);
$current .= $venuename.',';
file_put_contents($file, $current);
?>
PHP 스크립트가 실행되고 가장 최근의 체크인 이름을 입력했을 때 각 사용자의 텍스트 파일은 어떻게 생겼는지.
Venue Name, Venue Name, Venue Name, Venue Name
도움이 될만한 정보가 있으면 알려주세요.
마틴으로 시작하는 아이디어가 있습니까? PHP를 처음 접했을 때 (위의 PHP가 제가 작성한 PHP 중 가장 많은 것입니다). 신속한 답변을 해주셔서 감사드립니다. –