Skip to content

Custom HTTP Headers #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
steved1982 opened this issue Sep 12, 2015 · 3 comments
Open

Custom HTTP Headers #25

steved1982 opened this issue Sep 12, 2015 · 3 comments

Comments

@steved1982
Copy link

Diffbot allows Custom HTTP Headers like X-Forward-Cookie.

How can I set these using this system?

My current code is just:
$api = $diffbot->createProductAPI($_POST["siteURL"]);

@Swader
Copy link
Owner

Swader commented Sep 13, 2015

This is currently not implemented directly. However, I believe you can work around this by modifying the HttpClient used by the Diffbot class. It's just a Guzzle5 HTTPClient, so take it out with getHttpClient and change the headers you need, then set it again with setHttpClient. Some helpful docs could be these.

I'll look into this some more during the course of next week - currently, I'm writing the full client docs.

@Swader
Copy link
Owner

Swader commented Nov 7, 2015

@steved1982 I know it's been a while since this has been dealt with, but the client now implements PSR-7, so you can set custom headers by simply tweaking the client instance you use. Details about what was done and why in the 1.0 update are here.

@justinyost
Copy link
Contributor

@Swader This actually doesn't work because you typehinted to the implementing class and not an interface, so we can't swap out the class on the fly.

I've attempted this using both Guzzle as well as HttpPlug's PluginClient instance. both of which fail.

An example:

1) App\Tests\TestCase\Products\Vendors\DiffbotVendorTest::testVendor
TypeError: Argument 1 passed to Swader\Diffbot\Diffbot::setHttpClient() must be an instance of Http\Client\Common\HttpMethodsClient or null, instance of Http\Client\Common\PluginClient given, called in /home/vagrant/phoenix/app/Products/Vendors/DiffbotVendor.php on line 269

/home/vagrant/phoenix/vendor/swader/diffbot-php-client/src/Diffbot.php:98

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants