1

I am trying to using guzzle to pass the referer as mentioned by one of the stackoverflow user on one of my question asked here: related stackoverflow question unresolved

require_once("../plugins/Guzzle/vendor/autoload.php");

    //use GuzzleHttp\Client;
    $headers = ['Referer' => 'https://mywebsite.com'];  
    $httpClient = new Client([
'headers' => $headers
]);

but above through the error: syntax error, unexpected '[' and nothing works.:(

So can anyone please help me to find my mistake or what I am doing wrong here.

This question is a bit different as after improving guzzle to resolve the previous "referer" error. I end up with this new guzzle error.

So both questions have it's own issue.

Thanks

Jimil
  • 650
  • 2
  • 14
  • 37
  • Try edit your original question instead of posting new one – Gasol Oct 01 '19 at 03:00
  • Possible duplicate of [How to resolve Please ensure that the client is sending referer or use the API Console to remove the referer restrictions](https://stackoverflow.com/questions/58128189/how-to-resolve-please-ensure-that-the-client-is-sending-referer-or-use-the-api-c) – Gasol Oct 01 '19 at 03:01
  • There is no syntax on your snippet, Maybe it contains unprintable characters, Please provide full sample or hexdump output of sample. – Gasol Oct 01 '19 at 04:48
  • Hey @Gasol What kind of sample you required as I have already provided my full code on my linked question and the code snippet I have provided in this question contain the code which returning me error. So am I writing the wrong code for guzzle to get referer – Jimil Oct 01 '19 at 05:15
  • Which version of PHP do you run? Short array syntax ([] pair) is available since PHP 5.4, Please see https://www.php.net/manual/en/migration54.new-features.php for details. – Gasol Oct 01 '19 at 06:20
  • Run command with `php -V` to see the PHP version. – Gasol Oct 01 '19 at 06:21
  • hi @Gasol, we are running php v 5.3.29. I know it's bit old version and we are trying to upgrading it to php 7 but as you know this may take time for live system. So can you please suggest how I can run this guzzle code in php v 5.3.29 – Jimil Oct 01 '19 at 06:38
  • 1
    Just transform `[]` to `array()` – Gasol Oct 01 '19 at 06:47
  • Hi @Gasol I tried with that but still nothing works. Don't know what to do here:( – Jimil Oct 01 '19 at 10:03
  • Following is my change: $headers = ['Referer' => 'https://website.com']; $httpClient = new Client(array( 'headers' => $headers )); – Jimil Oct 01 '19 at 10:03
  • The assignment of variable $headers also needs to be transform with array form (`array()`) – Gasol Oct 01 '19 at 10:06
  • Hi @Gasol I have already done that thanks. – Jimil Oct 03 '19 at 22:07
  • Possible duplicate of [PHP parse/syntax errors; and how to solve them?](https://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them) – Dharman Oct 03 '19 at 23:55

0 Answers0