Sunday, July 3, 2011

Edit the link name on your post.


Our latest version now supports the addition of an action to a post that allows you to control the name of the link that is displayed to the FB user.  You can only add one action item and this is the format to use.

Dim
P As New Post
P.name = "test name"
P.message = "test message"
P.link = "cnn.com"
P.caption = "test caption"

Dim A As New ActionObj
A.name = "Comment Now"
A.link = "http://www.cnn.com"
P.actions.Add(A)
Posts.PublishCreate("me", P)

Wednesday, May 25, 2011

How to Comment on a Post

Imports Branches.FBAPI
...
Dim SI As New SessionInfo("[access_token]"))
Dim Posts = New Functions.Posts(SI)
Dim C As New Comment
C.message = "test comment"
Posts.PublishCreate("[objectID to post comment to]", C)

Posts and Comments Retrieval

This is an example of how to get a list of posts on a users wall and read any comments on those posts. You can also request comments for a specific post.

Imports Branches.FBAPI
...
Dim SI As New SessionInfo("[access_token]"))
Dim Req New Functions.Requests(SI)
For Each P In Req.GetPosts("me")
      TestContext.WriteLine(P.id)
      TestContext.WriteLine(P.from.name)
      TestContext.WriteLine(P.message)
      TestContext.WriteLine(P.link)
      TestContext.WriteLine(P.comments.count)
      'Return comments from data on post
      For Each C In P.comments.data
            TestContext.WriteLine(C.from.name)
            TestContext.WriteLine("Comment: " & C.message)
      Next
      'Return comments for a specific postID
      Dim C2 = Req.GetComments(P.id)
      For Each C In C2
            TestContext.WriteLine(C.from.name)
            TestContext.WriteLine("Comment: " & C.message)
      Next
Next

The above emaple is based on unit testing code

Working with friends and friend lists

To get a list of a user’s friends you can use two methods

1.    Get a list of all the friends for a use.
2.    Get a list of custom lists that the user has created and then view the friends for that particular list.

This is code from our unit testing but you can replace the testcontext.writeline with your preferred output method

Imports Branches.FBAPI
...
Dim SI As New SessionInfo("[access_token]"))
Dim Req As New Functions.Requests(SI)
 ' Get a list of a users friends
For Each [Friend] In Req.GetFriends
       TestContext.WriteLine([Friend].name)
Next
 ' Get a list of friend liss and then return the users for that list.
Getting Friend Lists
For Each FriendList In Req.GetFriendLists
       TestContext.WriteLine(FriendList.name)
       For Each [Friend] In Req.GetFriendList(FriendList.id)
              TestContext.WriteLine("     " & [Friend].name)
       Next
Next

Friday, April 22, 2011

Video Upload Just Added: How to publish a video 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 video to the server.

Dim FB As New SessionInfo("[access_token]")
Dim Posts = New Functions.Posts(FB)
Dim img As String = "[Local video 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 VideoID = Posts.PublishVideo("[Album ID]", "[title]", "[description]", B)   
  
Tagging users in videos is not yet supported by Facebook.

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)

New tutorial Video to get you started

I've put together a tutorial video to help you get up and running with the API.

Monday, April 18, 2011

New Facebook API tool for .NET

 Don't waste your time with open source projects that aren't supported, lack documentation and require guessing games to implement. 

Try out a fresh, clean and simple alternative to work with Facebook from your own website or application.

Branches FBAPI:
  • Easy to use 
  • Strongly typed to make debugging easier.
  • Use it in any .NET project or langauge, (VB, C#, etc) from the 2.0 framework and up.
  • Supports most major graph api functions
  • Supported and maintained as the graph changes in the future.

Provides built in mechanism to validate users on your ASP.NET site without having to fiddle with httpRequests, formatting and cryptic messages.

View a list of currently supported functions.

Download Free Trial Now - free for up to 30 days

Sample Code 

Making Requests

Imports Branches.FBAPI
...
Dim SI As New SessionInfo("[access_token]"))
Dim Req New Functions.Requests(SI)
Dim User = Req.GetUserInfo("[optional user ID]")
Response.Write(U.name)

Making Posts

Imports Branches.FBAPI
...
Dim SI As New SessionInfo("[access_token]"))
Dim Posts = New Functions.Posts(SI)
Dim P As New Post
P.name = "name of post"
P.message = "message"
P.link = "www.cnn.com"
P.caption = "my caption"
Posts.PublishCreate("[object ID to post to]", P)
Dim PostID = P.id

Authenticating Users

Imports Branches.FBAPI
...
Dim SI As New SessionInfo("[application_id]","applicaiton_secret")
'Redirects user to facebooks
SI.AuthenticateUser("http://[my url]", New SessionInfo.PermissionsEnum(){SessionInfo.PermissionsEnum.email, SessionInfo.PermissionsEnum.read_stream}))
'Called when the user is returned to your page
Dim FSR = SI.ReadFacebooAuthResponse
Response.Write(FSR.Access_Token)
Response.Write(FSR.UserID)