无法发布OpenGraph故事:OAuthException,发生了未知错误,测试用户

时间:2016-09-25 12:52:29

标签: ios facebook facebook-opengraph opengraph facebook-share

我正试图将一个OpenGraph故事发布到Facebook。 publish_actions尚未获得批准(尚未提交审批),但我正在使用该应用的测试用户,因此应该可以使用。这是我的代码:

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()
}

这是完整的日志:

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.}}

有什么问题?

刚刚尝试使用管理员帐户,非测试用户,也无法正常工作。

2 个答案:

答案 0 :(得分:0)

原来它必须是using (StreamReader sr = new StreamReader(pipeClient)) { string temp = sr.ReadLine(); Console.WriteLine("blah"); // prints while server sleeps Console.WriteLine("Received from server: {0}", temp); // prints while server is sleeping Thread.Sleep(10000); temp = sr.ReadLine(); Console.WriteLine("Received from server: {0}", temp); } 而不是"og:type": "testapp:location" ...

答案 1 :(得分:0)

我通过在Facebook应用程序设置中启用“publish_actions”并在“位置”中指向正确的Facebook页面ID来解决此问题。

您可以在此处查看位置ID - https://findmyfbid.com/

相关问题