S
S
Supme2013-11-19 12:59:19
Google
Supme, 2013-11-19 12:59:19

How to change user signatures in PHP using Google API?

I would like to automate the change of signatures. There is a PHP client , there is a description of the API for working with it.
I try like this:

require_once "google-api-php-client/src/Google_Client.php";
$client = new Google_Client();
$client->setApplicationName( 'Signature creator' );
$client->setClientId( CLIENT_ID );
$client->setAccessType( 'offline_access');
$client->setAssertionCredentials(
    new Google_AssertionCredentials(
        SERVICE_EMAIL,
        array(
            '<a href="https://apps-apis.google.com/a/feeds/emailsettings/">https://apps-apis.google.com/a/feeds/emailsettings/</a>',
            '<a href="https://apps-apis.google.com/a/feeds/groups/">https://apps-apis.google.com/a/feeds/groups/</a>',
            '<a href="https://apps-apis.google.com/a/feeds/alias/">https://apps-apis.google.com/a/feeds/alias/</a>',
            '<a href="https://apps-apis.google.com/a/feeds/user/">https://apps-apis.google.com/a/feeds/user/</a>'),
            file_get_contents( KEY_FILE_PATH )
        )
    );
$client->setUseObjects( true );

$domain = "domen.ru";
$user = rawurlencode("user");

$req = new Google_HttpRequest("<a href="https://apps-apis.google.com/a/feeds/emailsettings/2.0/%24domain/%24user/signature">https://apps-apis.google.com/a/feeds/emailsettings/2.0/$domain/$user/signature</a>");
$resp = $client::getIo()->authenticatedRequest($req);
print "Signature:" . $resp->getResponseBody();


Returns:
Signature:
You are not authorized to access this API.
Error 403

In domain security for CLIENT_ID added:
<a href="https://apps-apis.google.com/a/feeds/alias/">https://apps-apis.google.com/a/feeds/alias/</a> 
<a href="https://apps-apis.google.com/a/feeds/emailsettings/">https://apps-apis.google.com/a/feeds/emailsettings/</a> 
Groups Provisioning  <a href="https://apps-apis.google.com/a/feeds/groups/">https://apps-apis.google.com/a/feeds/groups/</a> 
User Provisioning  <a href="https://apps-apis.google.com/a/feeds/user/">https://apps-apis.google.com/a/feeds/user/</a>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Supme, 2013-11-26
@Supme

I like to answer myself :)
I did it like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question