New question

Question:

Date: 06-03-2020 13:07:48 (In Spanish)

Publicar una entrada en blogger usando la Api V3 y php[Unanswered]

Intento enviar un Post a Blogger usando la Api v3 de Blogger Y Php . El código funciona bien pero tengo unas dudas de como actualizar el token sin dar nuevamente permisos pensé que con esta parte:

$client->setAccessType('offline');

No necesitaba actualizarlo.

Otra duda es por que no puedo enviar una imagen usando esta manera :

$post->setimages(array("url"=>"https://image.freepik.com/vector-gratis/casa-dos-pisos_1308-16176.jpg"));

No aparece la imagen publicada . Segun este enlace Posts: insert esa es la manera o eso entiendo .

Les dejo el código completo para que puedan entender y ayudarme .


require_once __DIR__.'/vendor/autoload.php';

$scriptUri = "http://".$_SERVER["HTTP_HOST"].$_SERVER['PHP_SELF'];

$client = new Google_Client();
$client->setApplicationName('B'); //name of the application
$client->setAuthConfig('client_secret.json');
$client->setRedirectUri($scriptUri); //redirects to same url
$client->setApprovalPrompt("force");
$client->setAccessType('offline'); // default: offline
$client->setApprovalPrompt("consent");
$client->addScope(Google_Service_Blogger::BLOGGER);
$client->setIncludeGrantedScopes(true); // incremental auth
$guzzleClient = new \GuzzleHttp\Client(array('curl' => array(CURLOPT_SSL_VERIFYPEER => false)));
$client->setHttpClient($guzzleClient);

$service = new Google_Service_Blogger($client);
$blog = $service->blogs->getByUrl('http://whatsapp.mx/');
//this is part for sending post into blogger, which is getting
//error
$post = new Google_Service_Blogger_Post();
$post->setTitle('poner imagen 3');
$post->setimages(array("url"=>"https://image.freepik.com/vector-gratis/casa-dos-pisos_1308-16176.jpg"));
$post->setLabels(array('Label1', 'Label2'));
$post->setContent("plantilla.html");
$service->posts->insert('203422', $post);

Esta parte tampoco funciona como yo espero.

$post->setContent("plantilla.html");

No publica el html de
"plantilla.html" 
y no se por que o como se logra y e buscado en Internet y no hay mucha información en español
Tags: API - PHP Votes: 0 - Answers: 0 - Views: 4 Share on: Google Facebook Twitter LinkedIn Link
 

Answers:

No replies for this question, be the first to answer.
To actively participate in the community first must authenticate, enter the system.Sign In
 
frjcbbae garagebible.com