RE: Re: Posting images in a blog post?

Gramps Gramps <[email protected]>
Newsgroups gmane.comp.web.blogger.api
Message-ID <CA+27=r2_=04wDxHsJYwrOuVirwqS00_K-4nh6fGCxE4CqRTUYg@mail.gmail.com>
Hi Darryl,



I implemented a small method in Java which uploads into Picasaweb and
returns the direct public URL to the image, which can be used inside your
posts in blogger.....here you go (mind the note in the end of this email):



*public* *static* String upload(String fullpathToImage)

    {

      //The *url* of the image

        String resultingURL = *new* String();



        *try*

            {

            System.*out*.print("[STEP 3/7]: Uploading image to PicasaWeb..."
);



            //Perform OAuth2 Authentication and get Credential

            GoogleCredential credential = GoogleOauth2Authentication

                                         .*GoogleOauth2Authentication*(

                                          Config.*GOOGLE_SCOPE_PICASA*,

                                          Config.
*GOOGLE_OAUTH_REFRESH_TOKEN_PICASA*,

                                          Config.
*GOOGLE_OAUTH_REFRESH_TOKEN_FILE_PICASA*);



            PicasawebService picasaWebSvc = *new* PicasawebService(Config.
*GOOGLE_APP_NAME*);

            picasaWebSvc.setOAuth2Credentials(credential);



            URL feedUrl = *new* URL("
https://picasaweb.google.com/data/feed/api/user/" + Config.*PICASAWEB_LOGIN*
+ "/albumid/" + Config.*PICASAWEB_ALBUM_ID*);



            MediaFileSource myMedia = *new* MediaFileSource(*new* File(
fullpathToImage), "image/jpeg");

            PhotoEntry returnedPhoto = picasaWebSvc.insert(feedUrl,
PhotoEntry.*class*, myMedia);



            resultingURL = returnedPhoto.getMediaContents().get(0).getUrl();



            *if* (resultingURL.toLowerCase().contains("please check your
firewall") || resultingURL.toLowerCase().contains("error"))

                {

                *throw* *new* Exception("The Windows Firewall seems to be
blocking the upload...");

                }



            System.*out*.println("...DONE!");

            System.*out*.println("Cover page URL: " + resultingURL);

            }

        *catch* (Exception e)

            {

            System.*err*.println("[BloggerImageUploader.java]: There was an
error: " + e.getStackTrace());

            *return* "";

            }



    //The result

    *return* resultingURL;

    }



Note: The GoogleOauth2Authentication.*GoogleOauth2Authentication(...) *method
simply performs the OAuth2 authentication and retrieval of a valid access
token to be used for accessing the PicasaWeb service..



Hope it is useful,

Cheers,

Gizmo





*From:* [email protected] [mailto:[email protected]] *On
Behalf Of *John Wood
*Sent:* 23 June 2015 22:16
*To:* [email protected]
*Subject:* Re: [bloggerDev] Re: Posting images in a blog post?



Not sure what language or o/s you're using, but I use the python
PhotoService api for this -
http://gdata-python-client.googlecode.com/svn/trunk/pydocs/gdata.photos.service.html

I add an image using InsertPhotoSimple()

To get the url and use it in a blog post, I do the following



self._gdiclient = gdata.photos.service.PhotosService (self._user,
                                                             self._password,
                                                             self._source)



I then get the list of PhotoEntry objects for the relevant album

           album = self._getAlbumFeed (albumname)  # uses
self._gdclient.GetUserFeed to get album names
            photolist = self._gdclient.GetFeed (album.GetPhotosUri()).entry
            for p in photolist :
                self._debug ("    photo [{0}]", p.title.text)

When I match on the photo name that I want, I call photoentry.GetMediaURL()
to get the image url.
One thing to note is that part of this url is an sXXX component, where XXX
is the size of the image. You can

modify this to get google to return different sized images when the link is
clicked, which is quite useful.

Like I said, I don't know what language or o/s you're doing this from, but
the above is part of a command line

unix/windows script that I use to post blog entries, so hopefully it's of
use.




On 20 June 2015 at 19:13, Darryl L. Pierce <[email protected]> wrote:

Can anybody point to an API set for uploading images to PIcasa to be
used in a BLogger post?

On Thu, Jun 18, 2015 at 10:23 AM, Darryl L. Pierce <[email protected]>
wrote:
> Is there a simple example for publishing images with a blog post?
>
> --
> Darryl L. Pierce <[email protected]>
> http://mcpierce.blogspot.com/
> Famous last words:
>    "I wonder what happens if we do it this way?"



--
Darryl L. Pierce <[email protected]>
"What do you care what people think, Mr. Feynman?"

--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/bloggerdev.
For more options, visit https://groups.google.com/d/optout.



-- 
You received this message because you are subscribed to a topic in the
Google Groups "Blogger Developer Group" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/bloggerdev/_h56e-J11j4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
[email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/bloggerdev.
For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/bloggerdev.
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.