简体   繁体   中英

Facebook Open Graph Stories in iOS successfully creates an object but cannot post to fb timeline

I am trying to implement Open Graph Stories in iOS of facebook as shown in here: https://developers.facebook.com/docs/sharing/opengraph/ios#custom

I need to post it to facebook via custom interface, not with facebook share dialog.

So far, I can successfully create an open graph object per request, it does not return any error but does not post it to Facebook timeline neither. All I see in xcode is: postId: 113077439054125, completionGesture: post

I am not sure what goes wrong. Here is my code snippet:

            var photo = FBSDKSharePhoto(imageURL: imgUrl, userGenerated: false)
            var properties : [NSObject : AnyObject] = [
                "og:type"  : "video.movie",
                "og:title" : "TEST TITLE",
                "og:image" : "https://www.facebook.com/images/fb_icon_325x325.png",
                "fb:explicitly_shared" : true]

            var object = FBSDKShareOpenGraphObject(properties: properties)
            var shareApi = FBSDKShareAPI()

            var action = FBSDKShareOpenGraphAction(type: "MYNAMESPACE:myAction", object: object, key: "movie")

            var content = FBSDKShareOpenGraphContent()
            content.action = action
            content.previewPropertyName = "movie"
            shareApi.delegate = self
            shareApi.shareContent = content
            shareApi.share()

I've been struggling with it for some time by now. Any help would be appreciated.

Thanks.

You should have solved it. If not, did you get the token for publish_actions permission? This is how you can get it:

  1. Go to Graph API Explorer.
  2. Select your application.
  3. Click "Get User Access Token".
  4. Select "Extended Permissions" then "publish_actions".
  5. Click "Get Access Token".

That's it.

You have to get your app approved by Facebook in order to gain publish_actions right? When you login to Facebook what are the different access permissions that it shows. Usually you will get a line in the Facebook permission page that says this app does not let you post to timeline or something like that.

What you can try is to create Test Users and use it to login. Test users get all the permissions that you ask for since they are separate from normal users. Note that these are not same as Testers which are still normal FB accounts.

Try using Test Users and once your app is ready to go live, send it to Facebook from the app dashboard and once approved by them you should be good to go live.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM