Friday, April 22, 2011

How to publish a photo to Facebook

First make sure that you are authorized to publish to the user's feed with the **publish_stream** permission.

Then use the api commands to send the photo to the server.

Dim FB As New SessionInfo("[access_token]")
Dim Posts = New Functions.Posts(FB)
Dim img As String = "[Local picture Location]"
Dim F = New IO.FileStream(img, IO.FileMode.Open, IO.FileAccess.Read)
Dim B(F.Length - 1) As Byte
F.Read(B, 0, B.Length)
F.Close()
Dim PhotoID = Posts.PublishPhoto("[Album ID]", "[caption]", true, B, [Optional Tags if any])   
  
Tagging users is similar, just pass in a tag list when you call PublishPhoto 

Dim TL As New List(Of Tag)
Dim T As New Tag
T.id = "[userID]"
TL.Add(T)
Dim PhotoID = Posts.PublishPhoto("["me" or Album ID]", "[caption]", true, B, TL)

No comments:

Post a Comment