Skip to content
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

[reasonPhrase:GuzzleHttp\Psr7\Response:private] => Forbidden #2575

Open
HeartDisk opened this issue Mar 5, 2024 · 3 comments
Open

[reasonPhrase:GuzzleHttp\Psr7\Response:private] => Forbidden #2575

HeartDisk opened this issue Mar 5, 2024 · 3 comments

Comments

@HeartDisk
Copy link

HeartDisk commented Mar 5, 2024

I am trying to index url using php (CodeIgniter 4)
My Code Below.

namespace App\Libraries;
use Google_Client;
use GuzzleHttp;
use GuzzleHttp\Client;
use CodeIgniter\HTTP;

require_once ROOTPATH.'/vendor/google/apiclient-services/autoload.php';
class Google
{
// This function converts a string into slug format
public function add_to_index($url)
{
$googleCli = new Google_Client();
$googleCli->setAuthConfig(MY_JSON_FILE');
$googleCli->addScope('https://www.googleapis.com/auth/indexing');
// Get a Guzzle HTTP Client
$httpClient = $googleCli->authorize();
$endpoint = 'https://indexing.googleapis.com/v3/urlNotifications:publish';
// Define contents here. The structure of the content is described in the next step.
$content = '{
"url": "'.$url.'",
"type": "URL_UPDATED"
}';
$response = $httpClient->post($endpoint, [ 'body' => $content ]);
return $response;
}
}

its showing error

GuzzleHttp\Psr7\Response Object
(
[reasonPhrase:GuzzleHttp\Psr7\Response:private] => Forbidden
[statusCode:GuzzleHttp\Psr7\Response:private] => 403
[headers:GuzzleHttp\Psr7\Response:private] => Array
(
[Vary] => Array
(
[0] => X-Origin
[1] => Referer
[2] => Origin,Accept-Encoding
)

        [Content-Type] => Array
            (
                [0] => application/json; charset=UTF-8
            )

        [Date] => Array
            (
                [0] => Tue, 05 Mar 2024 08:23:16 GMT
            )

        [Server] => Array
            (
                [0] => ESF
            )

        [Cache-Control] => Array
            (
                [0] => private
            )

        [X-XSS-Protection] => Array
            (
                [0] => 0
            )

        [X-Frame-Options] => Array
            (
                [0] => SAMEORIGIN
            )

        [X-Content-Type-Options] => Array
            (
                [0] => nosniff
            )

        [Alt-Svc] => Array
            (
                [0] => h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
            )

        [Accept-Ranges] => Array
            (
                [0] => none
            )

        [Transfer-Encoding] => Array
            (
                [0] => chunked
            )

    )

[headerNames:GuzzleHttp\Psr7\Response:private] => Array
    (
        [vary] => Vary
        [content-type] => Content-Type
        [date] => Date
        [server] => Server
        [cache-control] => Cache-Control
        [x-xss-protection] => X-XSS-Protection
        [x-frame-options] => X-Frame-Options
        [x-content-type-options] => X-Content-Type-Options
        [alt-svc] => Alt-Svc
        [accept-ranges] => Accept-Ranges
        [transfer-encoding] => Transfer-Encoding
    )

[protocol:GuzzleHttp\Psr7\Response:private] => 1.1
[stream:GuzzleHttp\Psr7\Response:private] => GuzzleHttp\Psr7\Stream Object
    (
        [stream:GuzzleHttp\Psr7\Stream:private] => Resource id #220
        [size:GuzzleHttp\Psr7\Stream:private] => 
        [seekable:GuzzleHttp\Psr7\Stream:private] => 1
        [readable:GuzzleHttp\Psr7\Stream:private] => 1
        [writable:GuzzleHttp\Psr7\Stream:private] => 1
        [uri:GuzzleHttp\Psr7\Stream:private] => php://temp
        [customMetadata:GuzzleHttp\Psr7\Stream:private] => Array
            (
            )

    )

)

@svgta1
Copy link

svgta1 commented Mar 24, 2024

I've the same issue.

@svgta1
Copy link

svgta1 commented Mar 24, 2024

I've found the solution for me, verify for you : Web Search Indexing API was not activated.

Now, it's work.

@HeartDisk
Copy link
Author

I've found the solution for me, verify for you : Web Search Indexing API was not activated.

Now, it's work.

in my case it's activated and verified
still same issue

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

No branches or pull requests

2 participants