Showing posts with label Facebook. Show all posts
Showing posts with label Facebook. Show all posts

Friday, March 2, 2012

Facebook wall post parameters

As you already know, Facebook iPhone app is the most downloaded app on iTunes AppStore and sharing contents on Facebook has become an usual requirement in iPhone apps.

To post a feed on user's wall, we need to provide a set of values in the form of dictionary.

To post a feed, we use below method of facebook class,
[facebook dialog: @"feed"
               andParams: params
             andDelegate: self];

Here, 'params' is the dictionary that contains set of values to be posted on Facebook users wall.


A typical feed may look like below,

-(void)postToFacebook{
    NSString *description = @"Nice app to see movie trailers!";
    
    NSString* propString = @"{\"Download it free: \":{\"href\":\"http://itunes.apple.com/us/app/itunes-movie-trailers/id471966214?mt=8\",\"text\":\"On iTunes AppStore\"}}";
    
    // post FB dialog
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   @"iTunes Movie Trailers!", @"name",                             // Bold/blue name
                                   @"www.apple.com", @"caption",                                   // 1st line
                                   description, @"description",                                    // 2nd line
                                   @"http://itunes.apple.com/us/app/itunes-movie-trailers/id471966214?mt=8", @"link",
                                   @"http://www.blogcdn.com/www.tuaw.com/media/2011/10/imovietrailersapp.jpg", @"picture",
                                   propString, @"properties",
                                   nil];
    
    [facebook dialog: @"feed"
           andParams: params
         andDelegate: self];
}

Using this, the wall post on web page will look like below,
eg. wall post

Keep integrating Facebook in your application !!!



Tuesday, August 9, 2011

Displaying map in Facebook feed in iOS


Sharing images on Facebook feeds is desirable most of the times and can be accomplished by using the attachments in the params dictionary.

I went on a problem to post a Facebook feed that shares users current location as static map image.

The options available was to use a static image from google and use the url as value for 'picture' key in feeds parameters.
But, doing this didn't work. It didn't showed any image on the wall.

If you have a server that can cache and provide you the direct url of the static map image (generated by Microsoft Bing Map or Google Map), you can use that url for the feed purpose.

But, since I didn't had any, I had no option but to see for workarounds.

Searching for the solutions, certainly I found that Foursquare application does share the users location in feed. This foursquare proxy server url returns the static image of size 100x100 from Microsoft Bing Map. You can change the lat/long value in the url and get the desired map for your location.

It uses its proxy servers to generate and handle the map images.

The url for image is of below format,
https://foursquare.com/mapproxy/18.5163333/73.9299163/map.png

Its implementation code can look like below,


    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   kFacebookAppId, @"app_id",
                                   @"http://developers.facebook.com/docs/reference/dialogs/", @"link",
                                   @"https://foursquare.com/mapproxy/18.5163333/73.9299163/map.png", @"picture",
                                   @"Facebook Dialogs", @"name",
                                   @"Reference Documentation", @"caption",
                                   @"Dialogs provide a simple, consistent interface for apps to interact with users.", @"description",
                                   @"Facebook Dialogs are so easy!"@"message",
                                   nil];
    
    [facebook dialog:@"feed" andParams:params andDelegate:self];


Thanks and hope this helps.