Results 1 to 4 of 4

Thread: Add image to twitter post

  1. #1
    Join Date
    Feb 2013
    Posts
    6

    Default Add image to twitter post

    I am trying to add an image to my tweets but keep getting:
    Could not find a part of the path 'C:\Program Files\Common Files\Microsoft Shared\DevServer\11.0\~\Content\images\myimage.png '.

    This is what I have:
    Dim TweetString As String = "My Tweet"
    Dim ImageResource As IResource = New FileResource(http://mysite.com/images/myimage.png)
    twitter.TimelineOperations.UpdateStatus(TweetStrin g, ImageResource)

    My main question is why does is it looking on my hard drive instead of my defined path?
    can someone help please?

  2. #2
    Join Date
    Oct 2005
    Location
    Toulouse, France
    Posts
    1,409

    Default

    Hi,

    FileResource does not support http protocol.
    In core Spring.NET, you should use UrlResource that supports http, ftp protocols.
    Unfortunately, Spring.NET REST does not has UrlResource, so you need to download it yourself first:

    Try something like that:
    Code:
    Dim ImageStream As Stream=  WebRequest.Create("http://mysite.com/images/myimage.png").GetResponse().GetResponseStream()   //Or use HttpClient
    Dim ImageResource As IResource = New StreamResource(ImageStream)
    twitter.TimelineOperations.UpdateStatus(TweetStrin g, ImageResource)
    HTH,
    Bruno
    My english is as poor as my taylor is rich

  3. #3
    Join Date
    Feb 2013
    Posts
    6

    Default

    Hey Bruno. That is exactly what I was looking for. Works like a charm! Thank you for your help

  4. #4
    Join Date
    Jun 2013
    Posts
    3

    Default

    Yup indeed. I am looking for it to help me add image to twitter post these days. The code helps a lot. Thanks for your sharing.
    Best Regards,
    Arron



    |Image Processing SDK|



    Next Tomorrow is Another Day.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •