Skip to content

Add user-agent support#19

Merged
samwilson merged 5 commits into
mainfrom
user-agent
Jul 21, 2026
Merged

Add user-agent support#19
samwilson merged 5 commits into
mainfrom
user-agent

Conversation

@samwilson

Copy link
Copy Markdown
Member

No description provided.

Comment thread README.md Outdated

```php
$wsApi = new \Wikisource\Api\WikisourceApi();
$wgApi->setUserAgent( 'my-example-tool.toolforge.org' );

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samwilson This should be $wsApi instead of $wgApi, otherwise the example won't work :) Thanks

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, fixed.

Comment thread src/WikidataQuery.php
$client = new Client();
$client = new Client( [
'headers' => [
'User-Agent' => $this->userAgent,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also consider sending an Accept: application/sparql-results+xml headerr since this endpoint always expects SPARQL XML responses?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! Done.

@samwilson samwilson left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reviewing!

I think after upgrading to addwiki v4 we'll be able to pass the user agent through to every API call. But that can be a separate patch.

Comment thread README.md Outdated

```php
$wsApi = new \Wikisource\Api\WikisourceApi();
$wgApi->setUserAgent( 'my-example-tool.toolforge.org' );

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, fixed.

Comment thread src/WikidataQuery.php
$client = new Client();
$client = new Client( [
'headers' => [
'User-Agent' => $this->userAgent,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! Done.

@samwilson

Copy link
Copy Markdown
Member Author

Oh, actually there were version clashes, might as well do the upgrade now. :)

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires addwiki/mediawiki-api ^3 -> satisfiable by addwiki/mediawiki-api[3.0.0, 3.1.0].
    - addwiki/mediawiki-api 3.0.0 requires addwiki/mediawiki-api-base ^3.0 -> satisfiable by addwiki/mediawiki-api-base[3.0.0, 3.1.0].
    - addwiki/mediawiki-api 3.1.0 requires addwiki/mediawiki-api-base ^3.1 -> satisfiable by addwiki/mediawiki-api-base[3.1.0].
    - addwiki/mediawiki-api-base 3.0.0 requires guzzlehttp/guzzle ~6.3||~7.0 -> satisfiable by guzzlehttp/guzzle[7.15.1].
    - addwiki/mediawiki-api-base 3.0.0 requires guzzlehttp/promises ~1.0 -> satisfiable by guzzlehttp/promises[1.0.0, ..., 1.5.3].
    - guzzlehttp/guzzle 7.15.1 requires guzzlehttp/promises ^2.5.1 -> satisfiable by guzzlehttp/promises[2.5.1].
    - Conclusion: don't install addwiki/mediawiki-api-base 3.1.0 (conflict analysis result)
    - You can only install one version of a package, so only one of these can be installed: guzzlehttp/promises[1.0.0, ..., 1.5.3, 2.5.1].

@samwilson
samwilson merged commit d774151 into main Jul 21, 2026
4 checks passed
@samwilson
samwilson deleted the user-agent branch July 21, 2026 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants