Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $user_id = YOUR USER ID HERE;
- $oauth = 'YOUR OAUTH TOKEN HERE';
- $keys = array (
- "id",
- "createdAt",
- "type",
- "canonicalUrl",
- "canonicalPath",
- "timeZoneOffset",
- "editableUntil",
- "venue->id",
- "venue->name",
- "venue->contact->phone",
- "venue->contact->formattedPhone",
- "venue->contact->twitter",
- "venue->location->address",
- "venue->location->lat",
- "venue->location->lng",
- "venue->location->labeledLatLngs->0->label",
- "venue->location->labeledLatLngs->0->lat",
- "venue->location->labeledLatLngs->0->lng",
- "venue->location->postalCode",
- "venue->location->cc",
- "venue->location->city",
- "venue->location->state",
- "venue->location->country",
- "venue->location->contextLine",
- "venue->location->contextGeoId",
- "venue->location->formattedAddress->0",
- "venue->location->formattedAddress->1",
- "venue->canonicalUrl",
- "venue->canonicalPath",
- "venue->categories->0->id",
- "venue->categories->0->name",
- "venue->categories->0->pluralName",
- "venue->categories->0->shortName",
- "venue->categories->0->icon->prefix",
- "venue->categories->0->icon->mapPrefix",
- "venue->categories->0->icon->suffix",
- "venue->categories->0->primary",
- "venue->verified",
- "venue->stats->tipCount",
- "venue->stats->usersCount",
- "venue->stats->checkinsCount",
- "venue->url",
- "venue->urlSig",
- "venue->hasMenu",
- "venue->deliveryProviders->0->id",
- "venue->deliveryProviders->0->url",
- "venue->deliveryProviders->0->provider->name",
- "venue->deliveryProviders->0->provider->icon->prefix",
- "venue->deliveryProviders->0->provider->icon->sizes->0",
- "venue->deliveryProviders->0->provider->icon->sizes->1",
- "venue->deliveryProviders->0->provider->icon->name",
- "venue->delivery->id",
- "venue->delivery->url",
- "venue->delivery->provider->name",
- "venue->delivery->provider->icon->prefix",
- "venue->delivery->provider->icon->sizes->0",
- "venue->delivery->provider->icon->sizes->1",
- "venue->delivery->provider->icon->name",
- "venue->menu->type",
- "venue->menu->label",
- "venue->menu->anchor",
- "venue->menu->url",
- "venue->menu->mobileUrl",
- "venue->menu->canonicalPath",
- "venue->allowMenuUrlEdit",
- "venue->beenHere->lastCheckinExpiredAt",
- "venue->storeId",
- "venue->location->formattedAddress->3",
- "venue->inside->location->formattedAddress->3",
- "venue->closed",
- "venue->inside->closed",
- "venue->private",
- "venue->contact->instagram",
- "venue->contact->facebook",
- "venue->contact->facebookUsername",
- "venue->contact->facebookName",
- "venue->inside->id",
- "venue->inside->name",
- "venue->inside->contact->phone",
- "venue->inside->contact->formattedPhone",
- "venue->inside->contact->twitter",
- "venue->inside->contact->facebook",
- "venue->inside->contact->facebookUsername",
- "venue->inside->contact->facebookName",
- "venue->inside->location->address",
- "venue->inside->location->crossStreet",
- "venue->inside->location->lat",
- "venue->inside->location->lng",
- "venue->inside->location->labeledLatLngs->0->label",
- "venue->inside->location->labeledLatLngs->0->lat",
- "venue->inside->location->labeledLatLngs->0->lng",
- "venue->inside->location->postalCode",
- "venue->inside->location->cc",
- "venue->inside->location->city",
- "venue->inside->location->state",
- "venue->inside->location->country",
- "venue->inside->location->contextLine",
- "venue->inside->location->contextGeoId",
- "venue->inside->location->formattedAddress->0",
- "venue->inside->location->formattedAddress->1",
- "venue->inside->canonicalUrl",
- "venue->inside->canonicalPath",
- "venue->inside->categories->0->id",
- "venue->inside->categories->0->name",
- "venue->inside->categories->0->pluralName",
- "venue->inside->categories->0->shortName",
- "venue->inside->categories->0->icon->prefix",
- "venue->inside->categories->0->icon->mapPrefix",
- "venue->inside->categories->0->icon->suffix",
- "venue->inside->categories->0->primary",
- "venue->inside->verified",
- "venue->inside->stats->tipCount",
- "venue->inside->stats->usersCount",
- "venue->inside->stats->checkinsCount",
- "venue->inside->url",
- "venue->inside->urlSig",
- "venue->inside->allowMenuUrlEdit",
- "venue->inside->beenHere->lastCheckinExpiredAt",
- "venue->location->crossStreet",
- "venue->location->labeledLatLngs->1->label",
- "venue->location->labeledLatLngs->1->lat",
- "venue->location->labeledLatLngs->1->lng",
- "venue->reservations->url",
- "venue->reservations->provider",
- "venue->reservations->id",
- "venue->venuePage->id",
- "venue->menu->externalUrl",
- "venue->inside->reservations->url",
- "venue->inside->reservations->provider",
- "venue->inside->reservations->id",
- "venue->inside->venuePage->id",
- "venue->inside->storeId",
- "venue->venueRatingBlacklisted",
- "venue->inside->contact->instagram",
- "venue->inside->deliveryProviders->0->id",
- "venue->inside->deliveryProviders->0->url",
- "venue->inside->deliveryProviders->0->provider->name",
- "venue->inside->deliveryProviders->0->provider->icon->prefix",
- "venue->inside->deliveryProviders->0->provider->icon->sizes->0",
- "venue->inside->deliveryProviders->0->provider->icon->sizes->1",
- "venue->inside->deliveryProviders->0->provider->icon->name",
- "venue->inside->delivery->id",
- "venue->inside->delivery->url",
- "venue->inside->delivery->provider->name",
- "venue->inside->delivery->provider->icon->prefix",
- "venue->inside->delivery->provider->icon->sizes->0",
- "venue->inside->delivery->provider->icon->sizes->1",
- "venue->inside->delivery->provider->icon->name",
- "venue->location->neighborhood",
- "venue->inside->location->neighborhood",
- "venue->inside->hasMenu",
- "venue->inside->menu->type",
- "venue->inside->menu->label",
- "venue->inside->menu->anchor",
- "venue->inside->menu->url",
- "venue->inside->menu->mobileUrl",
- "venue->inside->menu->canonicalPath",
- "venue->locked",
- "venue->inside->locked",
- "venue->inside->location->labeledLatLngs->1->label",
- "venue->inside->location->labeledLatLngs->1->lat",
- "venue->inside->location->labeledLatLngs->1->lng",
- "venue->inside->venueRatingBlacklisted",
- "venue->location->formattedAddress->2",
- "venue->inside->location->formattedAddress->2",
- "venue->inside->menu->externalUrl",
- "venue->canonicalName",
- "venue->inside->canonicalName",
- "venue->location->isFuzzed",
- "like",
- "isMayor",
- "shout",
- "photos->count",
- "posts->count",
- "posts->textCount",
- "comments->count",
- "source->name",
- "source->url",
- "score->total",
- "likes->count",
- "likes->groups->0->type",
- "likes->groups->0->count",
- "likes->groups->0->items->0->id",
- "likes->groups->0->items->0->firstName",
- "likes->groups->0->items->0->lastName",
- "likes->groups->0->items->0->gender",
- "likes->groups->0->items->0->address",
- "likes->groups->0->items->0->city",
- "likes->groups->0->items->0->state",
- "likes->groups->0->items->0->countryCode",
- "likes->groups->0->items->0->relationship",
- "likes->groups->0->items->0->canonicalUrl",
- "likes->groups->0->items->0->canonicalPath",
- "likes->groups->0->items->0->photo->prefix",
- "likes->groups->0->items->0->photo->suffix",
- "likes->groups->0->items->0->isAnonymous",
- "likes->summary",
- "likes->groups->0->items->1->id",
- "likes->groups->0->items->1->firstName",
- "likes->groups->0->items->1->lastName",
- "likes->groups->0->items->1->gender",
- "likes->groups->0->items->1->address",
- "likes->groups->0->items->1->city",
- "likes->groups->0->items->1->state",
- "likes->groups->0->items->1->countryCode",
- "likes->groups->0->items->1->relationship",
- "likes->groups->0->items->1->canonicalUrl",
- "likes->groups->0->items->1->canonicalPath",
- "likes->groups->0->items->1->photo->prefix",
- "likes->groups->0->items->1->photo->suffix",
- "likes->groups->0->items->1->isAnonymous",
- "sticker->id",
- "sticker->name",
- "sticker->image->prefix",
- "sticker->image->sizes->0",
- "sticker->image->sizes->1",
- "sticker->image->sizes->2",
- "sticker->image->sizes->3",
- "sticker->image->name",
- "sticker->stickerType",
- "sticker->group->name",
- "sticker->group->index",
- "sticker->pickerPosition->page",
- "sticker->pickerPosition->index",
- "sticker->teaseText",
- "sticker->unlockText",
- "sticker->bonusText",
- "sticker->points",
- "sticker->bonusStatus",
- "stickerPowerup->bonusType",
- "stickerPowerup->value",
- "showStickerUpsell",
- "overlaps->count",
- "overlaps->summary",
- "overlaps->items->0->id",
- "overlaps->items->0->createdAt",
- "overlaps->items->0->type",
- "overlaps->items->0->canonicalUrl",
- "overlaps->items->0->canonicalPath",
- "overlaps->items->0->timeZoneOffset",
- "overlaps->items->0->user->id",
- "overlaps->items->0->user->firstName",
- "overlaps->items->0->user->lastName",
- "overlaps->items->0->user->gender",
- "overlaps->items->0->user->countryCode",
- "overlaps->items->0->user->relationship",
- "overlaps->items->0->user->canonicalUrl",
- "overlaps->items->0->user->canonicalPath",
- "overlaps->items->0->user->photo->prefix",
- "overlaps->items->0->user->photo->suffix",
- "overlaps->items->0->user->isAnonymous",
- "event->id",
- "event->name",
- "event->categories->0->id",
- "event->categories->0->name",
- "event->categories->0->pluralName",
- "event->categories->0->shortName",
- "event->categories->0->icon->prefix",
- "event->categories->0->icon->mapPrefix",
- "event->categories->0->icon->suffix",
- "event->categories->0->primary",
- "photos->items->0->id",
- "photos->items->0->createdAt",
- "photos->items->0->source->name",
- "photos->items->0->source->url",
- "photos->items->0->prefix",
- "photos->items->0->suffix",
- "photos->items->0->width",
- "photos->items->0->height",
- "photos->items->0->user->id",
- "photos->items->0->user->firstName",
- "photos->items->0->user->lastName",
- "photos->items->0->user->gender",
- "photos->items->0->user->countryCode",
- "photos->items->0->user->relationship",
- "photos->items->0->user->canonicalUrl",
- "photos->items->0->user->canonicalPath",
- "photos->items->0->user->photo->prefix",
- "photos->items->0->user->photo->suffix",
- "photos->items->0->user->isAnonymous",
- "photos->items->0->visibility",
- "photos->layout->name",
- "photos->items->0->hasSticker",
- "ratedAt",
- "likes->groups->0->items->2->id",
- "likes->groups->0->items->2->firstName",
- "likes->groups->0->items->2->lastName",
- "likes->groups->0->items->2->gender",
- "likes->groups->0->items->2->countryCode",
- "likes->groups->0->items->2->relationship",
- "likes->groups->0->items->2->canonicalUrl",
- "likes->groups->0->items->2->canonicalPath",
- "likes->groups->0->items->2->photo->prefix",
- "likes->groups->0->items->2->photo->suffix",
- "likes->groups->0->items->2->isAnonymous",
- "photos->items->1->id",
- "photos->items->1->createdAt",
- "photos->items->1->source->name",
- "photos->items->1->source->url",
- "photos->items->1->prefix",
- "photos->items->1->suffix",
- "photos->items->1->width",
- "photos->items->1->height",
- "photos->items->1->user->id",
- "photos->items->1->user->firstName",
- "photos->items->1->user->lastName",
- "photos->items->1->user->gender",
- "photos->items->1->user->countryCode",
- "photos->items->1->user->relationship",
- "photos->items->1->user->canonicalUrl",
- "photos->items->1->user->canonicalPath",
- "photos->items->1->user->photo->prefix",
- "photos->items->1->user->photo->suffix",
- "photos->items->1->user->isAnonymous",
- "photos->items->1->visibility",
- "photos->items->2->id",
- "photos->items->2->createdAt",
- "photos->items->2->source->name",
- "photos->items->2->source->url",
- "photos->items->2->prefix",
- "photos->items->2->suffix",
- "photos->items->2->width",
- "photos->items->2->height",
- "photos->items->2->user->id",
- "photos->items->2->user->firstName",
- "photos->items->2->user->lastName",
- "photos->items->2->user->gender",
- "photos->items->2->user->countryCode",
- "photos->items->2->user->relationship",
- "photos->items->2->user->canonicalUrl",
- "photos->items->2->user->canonicalPath",
- "photos->items->2->user->photo->prefix",
- "photos->items->2->user->photo->suffix",
- "photos->items->2->user->isAnonymous",
- "photos->items->2->visibility",
- "photos->items->3->id",
- "photos->items->3->createdAt",
- "photos->items->3->source->name",
- "photos->items->3->source->url",
- "photos->items->3->prefix",
- "photos->items->3->suffix",
- "photos->items->3->width",
- "photos->items->3->height",
- "photos->items->3->user->id",
- "photos->items->3->user->firstName",
- "photos->items->3->user->lastName",
- "photos->items->3->user->gender",
- "photos->items->3->user->countryCode",
- "photos->items->3->user->relationship",
- "photos->items->3->user->canonicalUrl",
- "photos->items->3->user->canonicalPath",
- "photos->items->3->user->photo->prefix",
- "photos->items->3->user->photo->suffix",
- "photos->items->3->user->isAnonymous",
- "photos->items->3->visibility",
- "photos->items->4->id",
- "photos->items->4->createdAt",
- "photos->items->4->source->name",
- "photos->items->4->source->url",
- "photos->items->4->prefix",
- "photos->items->4->suffix",
- "photos->items->4->width",
- "photos->items->4->height",
- "photos->items->4->user->id",
- "photos->items->4->user->firstName",
- "photos->items->4->user->lastName",
- "photos->items->4->user->gender",
- "photos->items->4->user->countryCode",
- "photos->items->4->user->relationship",
- "photos->items->4->user->canonicalUrl",
- "photos->items->4->user->canonicalPath",
- "photos->items->4->user->photo->prefix",
- "photos->items->4->user->photo->suffix",
- "photos->items->4->user->isAnonymous",
- "photos->items->4->visibility",
- "photos->items->5->id",
- "photos->items->5->createdAt",
- "photos->items->5->source->name",
- "photos->items->5->source->url",
- "photos->items->5->prefix",
- "photos->items->5->suffix",
- "photos->items->5->width",
- "photos->items->5->height",
- "photos->items->5->user->id",
- "photos->items->5->user->firstName",
- "photos->items->5->user->lastName",
- "photos->items->5->user->gender",
- "photos->items->5->user->countryCode",
- "photos->items->5->user->relationship",
- "photos->items->5->user->canonicalUrl",
- "photos->items->5->user->canonicalPath",
- "photos->items->5->user->photo->prefix",
- "photos->items->5->user->photo->suffix",
- "photos->items->5->user->isAnonymous",
- "photos->items->5->visibility",
- "photos->items->6->id",
- "photos->items->6->createdAt",
- "photos->items->6->source->name",
- "photos->items->6->source->url",
- "photos->items->6->prefix",
- "photos->items->6->suffix",
- "photos->items->6->width",
- "photos->items->6->height",
- "photos->items->6->user->id",
- "photos->items->6->user->firstName",
- "photos->items->6->user->lastName",
- "photos->items->6->user->gender",
- "photos->items->6->user->countryCode",
- "photos->items->6->user->relationship",
- "photos->items->6->user->canonicalUrl",
- "photos->items->6->user->canonicalPath",
- "photos->items->6->user->photo->prefix",
- "photos->items->6->user->photo->suffix",
- "photos->items->6->user->isAnonymous",
- "photos->items->6->visibility",
- "photos->layout->top->id",
- "photos->layout->bottomLeft->id",
- "photos->layout->bottomRight->id",
- "photos->layout->left->id",
- "photos->layout->right->id",
- "likes->groups->1->type",
- "likes->groups->1->count",
- "likes->groups->1->items->0->id",
- "likes->groups->1->items->0->firstName",
- "likes->groups->1->items->0->lastName",
- "likes->groups->1->items->0->gender",
- "likes->groups->1->items->0->countryCode",
- "likes->groups->1->items->0->canonicalUrl",
- "likes->groups->1->items->0->canonicalPath",
- "likes->groups->1->items->0->photo->prefix",
- "likes->groups->1->items->0->photo->suffix",
- "likes->groups->1->items->0->isAnonymous",
- "likes->groups->1->items->0->address",
- "likes->groups->1->items->0->city",
- "likes->groups->1->items->0->state",
- "likes->groups->1->items->0->relationship",
- "likes->groups->0->items->2->address",
- "likes->groups->0->items->2->city",
- "likes->groups->0->items->2->state",
- "sticker->effects->0->type",
- "sticker->effects->0->detail->prefix",
- "sticker->effects->0->detail->sizes->0",
- "sticker->effects->0->detail->name",
- "venue->location->formattedAddress->4",
- "venue->inside->location->formattedAddress->4",
- "entities->0->indices->0",
- "entities->0->indices->1",
- "entities->0->type",
- "entities->0->id",
- "entities->1->indices->0",
- "entities->1->indices->1",
- "entities->1->type",
- "entities->1->id",
- "with->0->id",
- "with->0->firstName",
- "with->0->lastName",
- "with->0->gender",
- "with->0->countryCode",
- "with->0->relationship",
- "with->0->canonicalUrl",
- "with->0->canonicalPath",
- "with->0->photo->prefix",
- "with->0->photo->suffix",
- "with->0->isAnonymous",
- "with->1->id",
- "with->1->firstName",
- "with->1->lastName",
- "with->1->gender",
- "with->1->countryCode",
- "with->1->relationship",
- "with->1->canonicalUrl",
- "with->1->canonicalPath",
- "with->1->photo->prefix",
- "with->1->photo->suffix",
- "with->1->isAnonymous",
- "overlaps->items->0->createdBy->id",
- "overlaps->items->0->createdBy->firstName",
- "overlaps->items->0->createdBy->lastName",
- "overlaps->items->0->createdBy->gender",
- "overlaps->items->0->createdBy->countryCode",
- "overlaps->items->0->createdBy->relationship",
- "overlaps->items->0->createdBy->canonicalUrl",
- "overlaps->items->0->createdBy->canonicalPath",
- "overlaps->items->0->createdBy->photo->prefix",
- "overlaps->items->0->createdBy->photo->suffix",
- "overlaps->items->0->createdBy->isAnonymous",
- "overlaps->items->1->id",
- "overlaps->items->1->createdAt",
- "overlaps->items->1->type",
- "overlaps->items->1->entities->0->indices->0",
- "overlaps->items->1->entities->0->indices->1",
- "overlaps->items->1->entities->0->type",
- "overlaps->items->1->entities->0->id",
- "overlaps->items->1->entities->1->indices->0",
- "overlaps->items->1->entities->1->indices->1",
- "overlaps->items->1->entities->1->type",
- "overlaps->items->1->entities->1->id",
- "overlaps->items->1->shout",
- "overlaps->items->1->canonicalUrl",
- "overlaps->items->1->canonicalPath",
- "overlaps->items->1->timeZoneOffset",
- "overlaps->items->1->with->0->id",
- "overlaps->items->1->with->0->firstName",
- "overlaps->items->1->with->0->lastName",
- "overlaps->items->1->with->0->gender",
- "overlaps->items->1->with->0->countryCode",
- "overlaps->items->1->with->0->relationship",
- "overlaps->items->1->with->0->canonicalUrl",
- "overlaps->items->1->with->0->canonicalPath",
- "overlaps->items->1->with->0->photo->prefix",
- "overlaps->items->1->with->0->photo->suffix",
- "overlaps->items->1->with->0->isAnonymous",
- "overlaps->items->1->with->1->id",
- "overlaps->items->1->with->1->firstName",
- "overlaps->items->1->with->1->lastName",
- "overlaps->items->1->with->1->gender",
- "overlaps->items->1->with->1->countryCode",
- "overlaps->items->1->with->1->relationship",
- "overlaps->items->1->with->1->canonicalUrl",
- "overlaps->items->1->with->1->canonicalPath",
- "overlaps->items->1->with->1->photo->prefix",
- "overlaps->items->1->with->1->photo->suffix",
- "overlaps->items->1->with->1->isAnonymous",
- "overlaps->items->1->user->id",
- "overlaps->items->1->user->firstName",
- "overlaps->items->1->user->lastName",
- "overlaps->items->1->user->gender",
- "overlaps->items->1->user->countryCode",
- "overlaps->items->1->user->relationship",
- "overlaps->items->1->user->canonicalUrl",
- "overlaps->items->1->user->canonicalPath",
- "overlaps->items->1->user->photo->prefix",
- "overlaps->items->1->user->photo->suffix",
- "overlaps->items->1->user->isAnonymous",
- "overlaps->items->1->createdBy->id",
- "overlaps->items->1->createdBy->firstName",
- "overlaps->items->1->createdBy->lastName",
- "overlaps->items->1->createdBy->gender",
- "overlaps->items->1->createdBy->countryCode",
- "overlaps->items->1->createdBy->relationship",
- "overlaps->items->1->createdBy->canonicalUrl",
- "overlaps->items->1->createdBy->canonicalPath",
- "overlaps->items->1->createdBy->photo->prefix",
- "overlaps->items->1->createdBy->photo->suffix",
- "overlaps->items->1->createdBy->isAnonymous",
- "overlaps->items->0->entities->0->indices->0",
- "overlaps->items->0->entities->0->indices->1",
- "overlaps->items->0->entities->0->type",
- "overlaps->items->0->entities->0->id",
- "overlaps->items->0->entities->1->indices->0",
- "overlaps->items->0->entities->1->indices->1",
- "overlaps->items->0->entities->1->type",
- "overlaps->items->0->entities->1->id",
- "overlaps->items->0->shout",
- "overlaps->items->0->with->0->id",
- "overlaps->items->0->with->0->firstName",
- "overlaps->items->0->with->0->lastName",
- "overlaps->items->0->with->0->gender",
- "overlaps->items->0->with->0->countryCode",
- "overlaps->items->0->with->0->relationship",
- "overlaps->items->0->with->0->canonicalUrl",
- "overlaps->items->0->with->0->canonicalPath",
- "overlaps->items->0->with->0->photo->prefix",
- "overlaps->items->0->with->0->photo->suffix",
- "overlaps->items->0->with->0->isAnonymous",
- "overlaps->items->0->with->1->id",
- "overlaps->items->0->with->1->firstName",
- "overlaps->items->0->with->1->lastName",
- "overlaps->items->0->with->1->gender",
- "overlaps->items->0->with->1->countryCode",
- "overlaps->items->0->with->1->relationship",
- "overlaps->items->0->with->1->canonicalUrl",
- "overlaps->items->0->with->1->canonicalPath",
- "overlaps->items->0->with->1->photo->prefix",
- "overlaps->items->0->with->1->photo->suffix",
- "overlaps->items->0->with->1->isAnonymous",
- "private",
- "visibility",
- );
- $offset = 0;
- $limit = 100;
- $ch = curl_init ("https://api.foursquare.com/v2/users/" . $user_id . "/historysearch?locale=en&v=20220920&offset=".$offset."&limit=1&sort=newestfirst&oauth_token=$oauth");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HEADER, false);
- $data = json_decode ( curl_exec ($ch), false);
- $checkins = $data->response->checkins->count;
- echo "Scraping $checkins checkins for user $user_id...\n";
- curl_close ($ch);
- $fhandle = fopen ("swarm-$user_id.csv", "w");
- if ($fhandle == null)
- {
- echo "Can't open file for writing\n";
- return;
- }
- $delim = '';
- foreach ($keys as $key)
- {
- fwrite ($fhandle, $delim . $key);
- $delim =',';
- }
- fwrite ($fhandle, "\n");
- while ($offset < $checkins)
- {
- echo " Grabbing checkins starting at $offset ...\n";
- $query_size = 0;
- if ($offset + $limit > $checkins)
- $query_size = $checkins - $offset;
- else
- $query_size = 100;
- $cd = get_checkin_data ($offset, $query_size, $user_id, $oauth);
- for ($index = 0; $index < count ($cd); $index ++)
- {
- $delim = "";
- foreach ($keys as &$key)
- {
- $fdata = extract_path ($cd [$index], explode ('->', $key));
- // Added 11/2/2022
- // Need to escape the comma that may appear in the string
- $fdata = str_replace (',', ',', $fdata);
- fwrite ($fhandle, $delim . $fdata);
- $delim = ",";
- }
- fwrite ($fhandle, "\n");
- // This code was used to create the list of json fields
- /*
- foreach ($cd [$index] as $key => $value)
- {
- $is_unique = true;
- for ($j = 0; $j < count ($keys); $j ++)
- {
- if ($keys [$j] === $key)
- $is_unique = false;
- }
- if ($is_unique)
- $keys [count ($keys)] = $key;
- }
- */
- }
- $offset = $offset + $query_size;
- sleep (5);
- }
- fclose ($fhandle);
- return ;
- function recursive_key ($prefix, $var)
- {
- global $keys;
- foreach ($var as $key => $value)
- {
- if (is_array ($value))
- recursive_key ($prefix . "->" . $key, $var [$key]);
- else
- {
- $is_unique = true;
- for ($j = 0; $j < count ($keys); $j ++)
- {
- if ($keys [$j] === $prefix . "->" . $key)
- $is_unique = false;
- }
- if ($is_unique)
- $keys [count ($keys)] = $prefix . "->" . $key;
- }
- }
- }
- function get_checkin_data ($o, $q, $u, $a)
- {
- $ch = curl_init ("https://api.foursquare.com/v2/users/" . $u . "/historysearch?locale=en&v=20220920&offset=" . $o . "&limit=" . $q . "&sort=newestfirst&oauth_token=$a");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HEADER, false);
- $data = json_decode ( curl_exec ($ch), true);
- curl_close ($ch);
- return $data ['response']['checkins']['items'];
- //return $data->response->checkins->items;
- }
- function extract_path (&$data, $path)
- {
- $rest = $data[$path[0]] ?? null;
- if ($rest == null)
- {
- return null;
- }
- if (count($path) == 1)
- return $rest;
- else
- return extract_path($rest, array_slice($path, 1));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement