teix
teix

Reputation: 61

Add a description on facebook using sharekit on iPhone

I explain you my problem.
I'm using Sharekit in my iphone app to share url on Facebook.
I can share my url but in the description section I have nothing (just a blank field).
and I would like to write some text.

I'm using this code in my file SHKFacebbok.m in the method send:

if (item.shareType == SHKShareTypeURL)
{
    self.pendingFacebookAction = SHKFacebookPendingStatus; 
    SHKFBStreamDialog* dialog = [[[SHKFBStreamDialog alloc] init] autorelease];
    dialog.delegate = self;

    dialog.userMessagePrompt = SHKLocalizedString(@"Votre réponse à cette question de merde:");
    dialog.attachment = [NSString stringWithFormat:
                         @"{\
                         \"name\":\"%@\",\
                         \"href\":\"%@\",\
                         \"media\":[{\"type\":\"image\",\"src\":\"http://www.samanddon.com/qdm.png\",\"href\":\"http://itunes.apple.com/fr/app/qdm/id453225639?mt=8\"}]\
                         }",
                         item.title == nil ? SHKEncodeURL(item.URL) : SHKEncode(item.title),
                         SHKEncodeURL(item.URL),
                         SHKEncodeURL(item.URL),
                         SHKEncodeURL(item.URL) 

                         ];

    dialog.defaultStatus = item.text;
    dialog.actionLinks = [NSString stringWithFormat:@"[{\"text\":\"Get %@\",\"href\":\"%@\"}]",
                          SHKEncode(SHKMyAppName),
                          SHKEncode(SHKMyAppURL)];
    [dialog show];

}

Someone know how can I write a description of the url?

Upvotes: 0

Views: 1319

Answers (2)

Joni
Joni

Reputation: 11

Try This too:
== On SHKFacebook.m ==

if (item.shareType == SHKShareTypeURL)
{
    self.pendingFacebookAction = SHKFacebookPendingStatus;

    SHKFBStreamDialog* dialog = [[[SHKFBStreamDialog alloc] init] autorelease];
    dialog.delegate = self;
    dialog.userMessagePrompt = SHKLocalizedString(@"Enter your message:");
    dialog.attachment = [NSString stringWithFormat:
                         @"{\
                         \"name\":\"%@\",\
                         \"href\":\"%@\",\
                         \"description\":\"%@\",\
                         \"media\":[{\"type\":\"image\",\"src\":\"%@\",\"href\":\"%@\"}]\
                         }",

                         item.title == nil ? SHKEncodeURL(item.URL) : SHKEncode(item.title),
                         SHKEncodeURL(item.URL),item.description, item.picture,SHKEncodeURL(item.URL)
                         ];

    dialog.defaultStatus = item.text;
    dialog.actionLinks = [NSString stringWithFormat:@"[{\"text\":\"Get %@\",\"href\":\"%@\"}]",
                          SHKEncode(SHKMyAppName),
                          SHKEncode(SHKMyAppURL)];
    [dialog show];

}


== On SHKItem.h ==
Add new item:

NSString *picture;
NSString *description;


and new property:

@property (nonatomic, retain)    NSString *picture;
@property (nonatomic, retain)   NSString *description;


== On SHKItem.m ==

 + (SHKItem *)URL:(NSURL *)url
{
    return [self URL:url title:nil description:nil picture:nil];
}

+ (SHKItem *)URL:(NSURL *)url title:(NSString *)title description:(NSString *)description picture:(NSString *)picture
{
    SHKItem *item = [[SHKItem alloc] init];
    item.shareType = SHKShareTypeURL;
    item.URL = url;
    item.title = title;
    item.description = description;
    item.picture = picture;

    return [item autorelease];
}


== How to use ==

SHKItem *item = [SHKItem URL:yoururl title:yourtitle description:yourdesc picture:yourpicture];
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
[actionSheet showFromToolbar:self.navigationController.toolbar];

Cheer! :D

Upvotes: 1

karse23
karse23

Reputation: 4115

Try this:

 dialog.attachment = [NSString stringWithFormat:
                                 @"{\
                                 \"name\":\"%@\",\
                                 \"href\":\"%@\",\
                                 \"description\":\"%@\",\
                                 \"media\":[{\"type\":\"image\",\"src\":\"http://www.apple.com/images/an_image.png.png\",\"href\":\"http://www.apple.com/\"}]\
                                 }",

                                 item.title == nil ? SHKEncodeURL(item.URL) : SHKEncode(item.title),
                                 SHKEncodeURL(item.URL),
                                 item.text
                                 ];

Note: Description cannot have line breaks like "\n". It doesn't work for me... Hope it helps.

Upvotes: 0

Related Questions