2015-07-03 129 views
1

我試圖添加一個圖像使用java api後。正如文檔中所描述的(https://developers.google.com/blogger/docs/3.0/reference/posts),我們可以通過一個URL來創建圖像。運行下面的代碼沒有幫助: Post content = new Post(); content.setTitle(...); content.setContent(...);博主api post image

List<Images> images=new ArrayList<Images>(); 
    for (PostAttachment attachment : attachmentsList) { 
      Images img=new Post.Images(); 
      String imageUrl="http://amazon.com/mybucket/example.jpg"; 
      img.setUrl(imageUrl); 
      images.add(img); 

     } 
     content.setImages(images); 
    } 
    // The request action. 
    Insert postsInsertAction = blogger.posts() 
      .insert(userId(), content); 

BTW,我看到,我們需要將圖像上傳到picassaweb(鏈接嗎?)。不知道他們是否仍然相關。

感謝, 弗雷迪

回答

1

我與Blogger的API現在的工作,並與蟒蛇,提供給張貼圖片不工作的codesample谷歌同樣的問題。

您必須通過html img-tag將圖像添加到您的內容中。

那它是如何工作的Python,但應該類似與Java:

request = posts.insert(blogId=your_blog_id, body = {"title" : "content title", "content" : "some text ... <img src = 'http://amazon.com/mybucket/example.jpg' title = 'test' alt = 'test' style='width:304px;height:228px;'>"}).execute()