You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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;
}
}
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
)
)
The text was updated successfully, but these errors were encountered: