Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,3 @@ APP_ENV=dev
APP_DEBUG=1
APP_SECRET=67d829bf61dc5f87a73fd814e2c9f622
###< symfony/framework-bundle ###

# meetup.com api - from https://www.meetup.com/api/oauth/list/ - complete in .env.local
MEETUP_COM_OAUTH_KEY=
MEETUP_COM_OAUTH_SECRET=
2 changes: 0 additions & 2 deletions .github/workflows/rector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ jobs:

steps:
- uses: actions/checkout@v6
with:
token: ${{ secrets.ACCESS_TOKEN || github.token }}

- uses: shivammathur/setup-php@v2
with:
Expand Down
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ cd friendsofphp.org
composer install
```

- Copy `.env` to `.env.local`
- Add your [Meetup.com API keys](https://secure.meetup.com/meetup_api/oauth_consumers/):

```dotenv
# .env.local
MEETUP_COM_OAUTH_KEY=...
MEETUP_COM_OAUTH_SECRET=...
```

- Update Meetup Data

```bash
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true
},
"platform": {
"php": "8.3"
}
},
"minimum-stability": "dev",
Expand Down
20 changes: 10 additions & 10 deletions src/MeetupCom/Meetup/MeetupComMeetupFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ public function createFromData(array $data): ?Meetup
$dateTimeImmutable = new DateTimeImmutable($data['startDate']);

return new Meetup(
$name,
html_entity_decode((string) $data[self::GROUP][self::NAME]),
$dateTimeImmutable->setTimezone(new DateTimeZone('UTC')),
$dateTimeImmutable->format('Y-m-d'),
$dateTimeImmutable->format('H:i'),
$data['url'],
$location->getCity(),
$location->getCountry(),
$location->getCoordinateLatitude(),
$location->getCoordinateLongitude(),
name: $name,
userGroupName: html_entity_decode((string) $data[self::GROUP][self::NAME]),
utcStartDateTime: $dateTimeImmutable->setTimezone(new DateTimeZone('UTC')),
localDate: $dateTimeImmutable->format('Y-m-d'),
localTime: $dateTimeImmutable->format('H:i'),
url: $data['url'],
city: $location->getCity(),
country: $location->getCountry(),
latitude: $location->getCoordinateLatitude(),
longitude: $location->getCoordinateLongitude(),
);
}

Expand Down
20 changes: 19 additions & 1 deletion src/MeetupCom/MeetupComCrawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public function getMeetupsByGroupSlug(string $groupSlug): array
continue;
}

if (! isset($schema['url'])) {
continue;
}

if (! isset($schema['organizer']['url'])) {
continue;
}
Expand All @@ -47,7 +51,21 @@ public function getMeetupsByGroupSlug(string $groupSlug): array
continue;
}

$data[] = $schema;
$crawler = $this->httpBrowser->request('GET', $schema['url']);
$innerStructuredDataElements = $crawler->filter('script[type="application/ld+json"]');

foreach ($innerStructuredDataElements as $innerStructuredDataElement) {
$innerSchema = Json::decode($innerStructuredDataElement->textContent, Json::FORCE_ARRAY);
if (! isset($innerSchema['@type'])) {
continue;
}

if ($innerSchema['@type'] !== 'Event') {
continue;
}

$data[] = $innerSchema;
}
}
}

Expand Down
5 changes: 3 additions & 2 deletions tests/MeetupCom/MeetupComCrawlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ public function testGetMeetupsByGroupSlug(): void
{
// Arrange
$smartFileSystem = new SmartFileSystem();
$mockResponse = new MockResponse($smartFileSystem->readFile(__DIR__ . '/fixtures/meetup_events.html'));
$mockHttpClient = new MockHttpClient([$mockResponse]);
$mockResponseList = new MockResponse($smartFileSystem->readFile(__DIR__ . '/fixtures/meetup_events.html'));
$mockResponseDetail = new MockResponse($smartFileSystem->readFile(__DIR__ . '/fixtures/meetup_detail.html'));
$mockHttpClient = new MockHttpClient([$mockResponseList, $mockResponseDetail]);
$httpBrowser = new HttpBrowser($mockHttpClient);
$meetupComCrawler = new MeetupComCrawler($httpBrowser);

Expand Down
19 changes: 19 additions & 0 deletions tests/MeetupCom/fixtures/meetup_detail.html

Large diffs are not rendered by default.