Discussion:
[bloggerDev] Using Java blogger API v3 to post on blog dynamically
mohamed sulibi
2014-11-24 20:16:16 UTC
Permalink
Hello,

I have two issues regarding using Java blogger API v3 to dynamically
posting posts to my blogger account http://mdarim.blogspot.com (
http://www.arabtip.com).

*First*

I used the following code to get credential for accessing my blog:

GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(JSON_FACTORY)
.setServiceAccountId(emailAddress)
.setServiceAccountPrivateKeyFromP12File(
new File(p12FileLocation))

.setServiceAccountScopes(Collections.singleton(BloggerScopes.BLOGGER))
.build();

credential.setAccessToken("zRLqmkM82626Uym9Uv1Jsdd");


Blogger blogger = new Blogger.Builder(httpTransport, JSON_FACTORY,
credential)
.setApplicationName("Blogger")
.build();
// .... rest of the code to prepare post and send it ......

*I set the access token above (*credential.setAccessToken*) that was
generated from the following google page:*
https://developers.google.com/oauthplayground

but this token is expired every 3600 seconds. so I visit the page again and
press the button "Refresh access token" to get another one and use it again
in above code.

*Is this the correct method of accessing my blog and dynamically posting
contents and articles programmatically?*


*Second*

In google developers console https://developers.google.com/console i saw
that I have 10000 requests/day and a limit of 1 request/second/user

*BUT*

after correctly posting dynamically using my above code around 50 posts
(note that I set a wait for around 5 seconds between a consecutive
requests), I started receiving the following error from the api call:

{
"code" : 403,
"errors" : [ {
"domain" : "usageLimits",
"message" : "Rate Limit Exceeded",
"reason" : "rateLimitExceeded"
} ],
"message" : "Rate Limit Exceeded"
}


I return to my quota page and I see that the requests that I send did not
decreased from my allowed requests per day !!!

Some my second question is:

*Does I forget a specific configuration for correctly manipulate my blog
dynamically ?*

Thank you in advance for your help and support.
--
You received this message because you are subscribed to the Google Groups "Blogger Developer Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bloggerdev+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/bloggerdev.
For more options, visit https://groups.google.com/d/optout.
mohamed sulibi
2014-11-25 07:37:40 UTC
Permalink
After googling about my problem I solve the first part by generating the
access token as describe in the following link:
https://developers.google.com/accounts/docs/OAuth2InstalledApp

but I still received the following error when posting to my blogger account
:-(:

Exception in thread "main"
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403
Forbidden
{
"code" : 403,
"errors" : [ {
"domain" : "usageLimits",
"message" : "Rate Limit Exceeded",
"reason" : "rateLimitExceeded"
} ],
"message" : "Rate Limit Exceeded"
}

But my remaining free quota is 9,985 requests/day
Post by mohamed sulibi
Hello,
I have two issues regarding using Java blogger API v3 to dynamically
posting posts to my blogger account http://mdarim.blogspot.com (
http://www.arabtip.com).
*First*
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(JSON_FACTORY)
.setServiceAccountId(emailAddress)
.setServiceAccountPrivateKeyFromP12File(
new File(p12FileLocation))
.setServiceAccountScopes(Collections.singleton(BloggerScopes.BLOGGER))
.build();
credential.setAccessToken("zRLqmkM82626Uym9Uv1Jsdd");
Blogger blogger = new Blogger.Builder(httpTransport, JSON_FACTORY,
credential)
.setApplicationName("Blogger")
.build();
// .... rest of the code to prepare post and send it ......
*I set the access token above (*credential.setAccessToken*) that was
generated from the following google page:*
https://developers.google.com/oauthplayground
but this token is expired every 3600 seconds. so I visit the page again
and press the button "Refresh access token" to get another one and use it
again in above code.
*Is this the correct method of accessing my blog and dynamically posting
contents and articles programmatically?*
*Second*
In google developers console https://developers.google.com/console i saw
that I have 10000 requests/day and a limit of 1 request/second/user
*BUT*
after correctly posting dynamically using my above code around 50 posts
(note that I set a wait for around 5 seconds between a consecutive
{
"code" : 403,
"errors" : [ {
"domain" : "usageLimits",
"message" : "Rate Limit Exceeded",
"reason" : "rateLimitExceeded"
} ],
"message" : "Rate Limit Exceeded"
}
I return to my quota page and I see that the requests that I send did not
decreased from my allowed requests per day !!!
*Does I forget a specific configuration for correctly manipulate my blog
dynamically ?*
Thank you in advance for your help and support.
--
You received this message because you are subscribed to the Google Groups "Blogger Developer Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bloggerdev+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/bloggerdev.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Search results for '[bloggerDev] Using Java blogger API v3 to post on blog dynamically' (Questions and Answers)
11
replies
Windows Vista?
started 2007-04-27 05:06:58 UTC
software
Loading...