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
16 changes: 0 additions & 16 deletions .github/workflows/autoTag.yml

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

on:
pull_request:
push:
branches: [main]

jobs:
test:
name: PHP ${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['8.1', '8.2', '8.3', '8.4', '8.5']
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: curl, json
coverage: none
- run: composer validate --strict
- uses: ramsey/composer-install@v3
- name: Lint
run: find src tests examples -name '*.php' -print0 | xargs -0 -n1 php -l > /dev/null
# Unit tests + client tests against a fake transport: no network or API key needed.
- run: vendor/bin/phpunit

release-readiness:
name: version + changelog
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: CHANGELOG.md has an entry for CapMonsterClient::VERSION
run: |
VERSION=$(sed -nE "s/.*const VERSION = '([^']+)'.*/\1/p" src/CapMonsterClient.php)
echo "version: $VERSION"
grep -q "^## \[$VERSION\]" CHANGELOG.md || { echo "CHANGELOG.md has no '## [$VERSION]' section"; exit 1; }
24 changes: 0 additions & 24 deletions .github/workflows/php.yml

This file was deleted.

62 changes: 62 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Release

# Tags `vX.Y.Z` and creates a GitHub Release when CapMonsterClient::VERSION on main has no tag yet;
# Packagist picks the new tag up through its GitHub hook. Any other push to main is a no-op.
# To release: bump CapMonsterClient::VERSION + add a `## [X.Y.Z]` section to CHANGELOG.md in a PR and merge it.
on:
push:
branches: [main]
workflow_dispatch:

concurrency:
group: release
cancel-in-progress: false

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Read version
id: v
run: echo "version=$(sed -nE "s/.*const VERSION = '([^']+)'.*/\1/p" src/CapMonsterClient.php)" >> "$GITHUB_OUTPUT"

- name: Already tagged?
id: tagged
run: |
if git rev-parse -q --verify "refs/tags/v${{ steps.v.outputs.version }}" > /dev/null; then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "v${{ steps.v.outputs.version }} already exists, nothing to release."
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi

- uses: shivammathur/setup-php@v2
if: steps.tagged.outputs.exists == 'false'
with:
php-version: '8.3'
coverage: none
- uses: ramsey/composer-install@v3
if: steps.tagged.outputs.exists == 'false'

- name: Checks before releasing
if: steps.tagged.outputs.exists == 'false'
run: |
grep -q "^## \[${{ steps.v.outputs.version }}\]" CHANGELOG.md \
|| { echo "CHANGELOG.md has no section for ${{ steps.v.outputs.version }}"; exit 1; }
vendor/bin/phpunit

- name: Tag and GitHub Release
if: steps.tagged.outputs.exists == 'false'
run: |
gh release create "v${{ steps.v.outputs.version }}" \
--target "${{ github.sha }}" \
--title "v${{ steps.v.outputs.version }}" \
--generate-notes
env:
GH_TOKEN: ${{ github.token }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/client/vendor
/vendor/
composer.lock
.phpunit.cache/
.phpunit.result.cache
.idea/
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Changelog

All notable changes to this package are documented here. The format follows
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), versions follow [SemVer](https://semver.org/).

## [2.0.0]

Full rewrite. **Breaking:** the 1.x API (`Client`, `*Request` classes in the global namespace,
`Result{result, message}`) is removed; see "Migrating from 1.x" in README.md.

### Added
- Composer package with PSR-4 autoloading (`Zennolab\CapMonsterCloud\`): works from `vendor/` in any project
(fixes #12 "Not compatible using composer"). Requires PHP 8.1+, `ext-curl`, `ext-json`; no runtime dependencies.
- `CapMonsterClient`: `solve()` (createTask + polling with a per-type schedule), low-level `createTask()` /
`getTaskResult()`, `getBalance()`. Errors are exceptions under `CapMonsterException`
(`ValidationException`, `CreateTaskException` / `GetResultException` / `GetBalanceException` with `errorCode`,
`TimeoutException`, `TransportException`, `UnexpectedHttpStatusException`, `MalformedResponseException`).
- `ClientOptions`: service URL, `softId`, per-request HTTP timeout, a proxy for the SDK's own requests
(http/https/socks4/socks5), polling-schedule override. Pluggable `HttpTransport` (default: curl, keep-alive).
- Request types matching the current API documentation: reCAPTCHA v2 / v2 Enterprise / v3 / v3 Enterprise,
reCAPTCHA click and Recognition ComplexImageTask, ImageToText, FunCaptcha, GeeTest v3/v4,
Turnstile (standard, Cloudflare Challenge token / cf_clearance, Waiting Room), Amazon WAF (3 variants),
Binance, MTCaptcha, Yidun, Prosopo, and CustomTask: DataDome, Imperva, TSPD, HUNT, Basilisk, TenDI, Alibaba,
Friendly Captcha, Altcha.
- Local validation of requests before anything is sent; the API key and proxy passwords are masked in
`var_dump()` / `print_r()`.

### Removed
- `HCaptchaRequest`, `ComplexImageHCaptchaRequest`, `ComplexImageFuncaptchaRequest`, `ComplexImageRequest`:
no longer in the API documentation.
- `*Proxyless` task types: the API now uses one task type per captcha with an optional proxy.

### Fixed
- `ImageToTextTask` sends `capMonsterModule` / `case` (documented names) instead of `CapMonsterModule` / `Case`.
104 changes: 0 additions & 104 deletions Client.php

This file was deleted.

Loading
Loading