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
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)
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