Skip to content

Custom HTTP Headers #25

Open
Open

Description

@steved1982

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"]);

Activity

  1. Swader commented on Sep 13, 2015

    @Swader
    Owner

    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.

  2. self-assigned this
    on Nov 7, 2015
  3. Swader commented on Nov 7, 2015

    @Swader
    Owner

    @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.

  4. justinyost commented on Jan 26, 2018

    @justinyost
    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

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions