Skip to content
This repository was archived by the owner on Aug 30, 2020. It is now read-only.
This repository was archived by the owner on Aug 30, 2020. It is now read-only.

"ipRefererBlocked" by google #1

Description

@juebel

Trying to use the package, I got the following response

In GoogleUrlShortener.php line 86:
Undefined property: stdClass::$id

and from the Google API:

(dump of $response at GoogleUrlShortnener.php:83)

object(stdClass)#1658 (1) {
["error"]=>
object(stdClass)#1657 (3) {
["errors"]=>
array(1) {
[0]=>
object(stdClass)#1654 (4) {
["domain"]=>
string(11) "usageLimits"
["reason"]=>
string(16) "ipRefererBlocked"
["message"]=>
string(148) "The request did not specify any referer. Please ensure that the client is sending referer or use the API Console to remove the referer restrictions."
["extendedHelp"]=>
string(75) "https://console.developers.google.com/apis/credentials?project=XXXXXXXXXXX"
}
}
["code"]=>
int(403)
["message"]=>
string(148) "The request did not specify any referer. Please ensure that the client is sending referer or use the API Console to remove the referer restrictions."
}
}

Detailed description

It is possible to solve it by indicating a generic referer via curl.

Possible implementation

I have added the following line:
(GoogleUrlShortnener.php:122)

    curl_setopt($this->curl, CURLOPT_REFERER, 'http://www.google.com');

Your environment

My composer.json
...
"require": {
"php": ">=7.0.0",
"fideloper/proxy": "~3.3",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0",
"simplepie/simplepie": "^1.5",
"tzsk/shorten-url": "^1.0",
"yangqi/htmldom": "^1.0"
...
I hope you find it useful

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions