0

I'm trying to post an OpenGraph story to Facebook. publish_actions was not yet approved(nor submitted for approval yet), but I am using a test user for that app, so it should work. Here is my code:

let loginManager: FBSDKLoginManager = FBSDKLoginManager()
loginManager.logInWithPublishPermissions(["publish_actions"], fromViewController: self, handler: { (result, error) in

    if error != nil
    {
        self.postOnFacebookSwitch.on = false
    }
    else
    {
        self.postOpenGraphStoryToFacebook()
    }
})

func postOpenGraphStoryToFacebook()
{
    NSLog("postOpenGraphStoryToFacebook()")            

    let object = FBSDKShareOpenGraphObject(properties: ["og:type": "location", "og:title": "test location title", "place:location:latitude": 12.2, "place:location:longitude": 13.2])

    let action = FBSDKShareOpenGraphAction()
    action.actionType = "testapp:check_in"
    action.setObject(object, forKey: "location")

    let content = FBSDKShareOpenGraphContent()
    content.action = action
    content.previewPropertyName = "location"

    let shareAPI = FBSDKShareAPI()
    shareAPI.delegate = self
    shareAPI.shareContent = content
    shareAPI.share()
}

Here is the full log:

2016-09-25 15:45:24.568 TestApp[72327:19648100] postOpenGraphStoryToFacebook()
2016-09-25 15:45:24.848 TestApp[72327:19648100] didFailWithError Error Domain=com.facebook.sdk.share Code=201 "(null)" UserInfo={NSUnderlyingError=0x8287e6a0 {Error Domain=com.facebook.sdk.core Code=8 "(null)" UserInfo={com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey=500, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=An unknown error has occurred., NSRecoveryAttempter=<_FBSDKTemporaryErrorRecoveryAttempter: 0x8287bb30>, com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode=1, com.facebook.sdk:FBSDKGraphRequestErrorCategoryKey=1, com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey=<CFBasicHash 0x8287f190 [0x3c7b1f8]>{type = mutable dict, count = 2,
entries =>
    1 : <CFString 0x82880450 [0x3c7b1f8]>{contents = "code"} = <CFNumber 0x796da9b0 [0x3c7b1f8]>{value = +500, type = kCFNumberSInt64Type}
    2 : <CFString 0x8f55ac [0x3c7b1f8]>{contents = "body"} = <CFBasicHash 0x8287e130 [0x3c7b1f8]>{type = immutable dict, count = 1,
entries =>
    2 : <CFString 0x8287e750 [0x3c7b1f8]>{contents = "error"} = <CFBasicHash 0x8287cc10 [0x3c7b1f8]>{type = immutable dict, count = 4,
entries =>
    0 : <CFString 0x8282aae0 [0x3c7b1f8]>{contents = "type"} = <CFString 0x8287a510 [0x3c7b1f8]>{contents = "OAuthException"}
    1 : <CFString 0x8287def0 [0x3c7b1f8]>{contents = "code"} = <CFNumber 0x7a906b70 [0x3c7b1f8]>{value = +1, type = kCFNumberSInt32Type}
    3 : <CFString 0x8287fdd0 [0x3c7b1f8]>{contents = "fbtrace_id"} = <CFString 0x8287f970 [0x3c7b1f8]>{contents = "C0APfOSCSX9"}
    5 : <CFString 0x8287db10 [0x3c7b1f8]>{contents = "message"} = <CFString 0x8287ba00 [0x3c7b1f8]>{contents = "An unknown error has occurred."}
}

}

}
, NSLocalizedRecoveryOptions=(
    OK
), NSLocalizedRecoverySuggestion=The server is temporarily busy, please try again.}}, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Error creating Open Graph object: Error Domain=com.facebook.sdk.core Code=8 "(null)" UserInfo={com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey=500, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=An unknown error has occurred., NSRecoveryAttempter=<_FBSDKTemporaryErrorRecoveryAttempter: 0x8287bb30>, com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode=1, com.facebook.sdk:FBSDKGraphRequestErrorCategoryKey=1, com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey=<CFBasicHash 0x8287f190 [0x3c7b1f8]>{type = mutable dict, count = 2,
entries =>
    1 : <CFString 0x82880450 [0x3c7b1f8]>{contents = "code"} = <CFNumber 0x796da9b0 [0x3c7b1f8]>{value = +500, type = kCFNumberSInt64Type}
    2 : <CFString 0x8f55ac [0x3c7b1f8]>{contents = "body"} = <CFBasicHash 0x8287e130 [0x3c7b1f8]>{type = immutable dict, count = 1,
entries =>
    2 : <CFString 0x8287e750 [0x3c7b1f8]>{contents = "error"} = <CFBasicHash 0x8287cc10 [0x3c7b1f8]>{type = immutable dict, count = 4,
entries =>
    0 : <CFString 0x8282aae0 [0x3c7b1f8]>{contents = "type"} = <CFString 0x8287a510 [0x3c7b1f8]>{contents = "OAuthException"}
    1 : <CFString 0x8287def0 [0x3c7b1f8]>{contents = "code"} = <CFNumber 0x7a906b70 [0x3c7b1f8]>{value = +1, type = kCFNumberSInt32Type}
    3 : <CFString 0x8287fdd0 [0x3c7b1f8]>{contents = "fbtrace_id"} = <CFString 0x8287f970 [0x3c7b1f8]>{contents = "C0APfOSCSX9"}
    5 : <CFString 0x8287db10 [0x3c7b1f8]>{contents = "message"} = <CFString 0x8287ba00 [0x3c7b1f8]>{contents = "An unknown error has occurred."}
}

}

}
, NSLocalizedRecoveryOptions=(
    OK
), NSLocalizedRecoverySuggestion=The server is temporarily busy, please try again.}}

What is wrong?

Just tried it with an administrator account, non-test user, doesn't work either.

Gintas_
  • 4,940
  • 12
  • 44
  • 87

2 Answers2

0

Turns out it must be "og:type": "testapp:location" instead of "og:type": "location"...

Gintas_
  • 4,940
  • 12
  • 44
  • 87
0

I solved such issue by enabling "publish_actions" in Facebook application settings and also pointing to correct Facebook page id in "location".

You can check location id here - https://findmyfbid.com/

  • Why link to a third-party site when you could describe the way to do this through the API? I'm not particularly familiar with the API, but [this](https://stackoverflow.com/a/5502227/1863564) seems to be a good way to do it without a shady third site. – Nic Nov 03 '17 at 20:48