Using Facebook Open Graph Story with map attachment (GeoPoint)

橙三吉。 提交于 2019-11-28 06:09:49

问题


I'm trying to create some Open Graph Story with map attachment using iOS SDK and I'm have some issues.

First of all I'm having issues with the object creation... I had set a object that inherits from 'Place'. So here is the first question "how to setup a GeoPoint property using iOS Facebook SDK?"... After so many tries, I gave up... So I created a object that inherist from 'Object' and I created a custom property named 'location' as GeoPoint. But this solution brings me to same question "how to setup a GeoPoint property using iOS Facebook SDK?"

All I need is create a Story with a map that shows the venue location.

Here is my object:

id<FBOpenGraphObject> openGraphObject = (id<FBOpenGraphObject>)[FBGraphObject openGraphObjectForPost];
[openGraphObject setType:@"appnamespace:venue"];
[openGraphObject setTitle:[currentVenue name]];
[openGraphObject setObject:@"en_US" forKey:@"og:locale"];
[openGraphObject setObject:[[currentVenue locationLatitude] stringValue] forKey:@"appnamespace:location:latitude"];
[openGraphObject setObject:[[currentVenue locationLongitude] stringValue] forKey:@"appnamespace:location:longitude"];

But don't works.

It appears in Facebook Browser Objects, but with only the name. The other properties are nil.

Someone can help me?


回答1:


The properties don't need to be prefixed by your appnamespace, and each ':' implies a new object or dictionary.

Try something like:

[openGraphObject setObject:@{@"latitude": [currentVenue locationLatitude], 
                             @"longitude": [currentVenue locationLongitude]}
                 forKey:@"location"];



回答2:


Your custom properties should be added in a dictionary named data. In my Facebook app I have an object (inheriting from Object) with a property named position which is a geo_point.

This is the code I use to create the object:

NSMutableDictionary<FBOpenGraphObject> *object = [FBGraphObject openGraphObjectForPost];
object.provisionedForPost = YES;
object[ @"title"] = @"Title";   // for og:title
object[ @"type"] = @"my_namespace:my_object";
object[ @"data" ] = @{ @"position": @{ @"latitude": @55, @"longitude": @12 }};


来源:https://stackoverflow.com/questions/19383645/using-facebook-open-graph-story-with-map-attachment-geopoint

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!