此问题可能与:Facebook Scores API not publishing open graph stories
有关我正确发布得分(在图表浏览器和活动日志中看起来不错),但是当我击败朋友的分数时会发生一些事情。我想Facebook应该在活动日志中记录类似“你打败你的朋友......”的内容,但不是那样,我的活动记录完全清楚。该应用程序中的所有活动都被删除了,我无法发布更多活动(如果我这样做,从那时起,活动中没有记录OG操作或其他分数,代码会给我一个成功的帖子。)
#pragma mark Score
void Facebook::postScore(long score) {
this->setDirtyScore(score);
Request::requestForMyScore([=](int error, const Vector<GraphScore *> &scores){
if (!error) {
if (scores.size()) {
log("Score: old: %ld - new: %ld", scores.at(0)->getScore(), score);
if (scores.at(0)->getScore() < score) {
this->doPostScore(score);
} else {
this->clearDirtyScore();
}
} else {
//No score
this->doPostScore(score);
}
}
})->execute();
}
void Facebook::doPostScore(long score) {
Request::requestForPostScore(score, [=](int error, bool success){
if (success) {
this->clearDirtyScore();
}
})->execute();
}
void Facebook::setDirtyScore(long score) {
_data->set(FacebookDataDirtyScoreKey, score);
}
long Facebook::getDirtyScore() {
return _data->getLong(FacebookDataDirtyScoreKey);
}
void Facebook::clearDirtyScore() {
_data->clear(FacebookDataDirtyScoreKey);
}
Request *Request::requestForScores(const ScoresRequestCallback &callback) {
string appId = Session::getActiveSession()->getAppId();
CCASSERT(appId.length() > 0, "Request::requestForScores - check your code sir");
Request *request = new Request(appId + "/scores");
if (callback) {
RequestCallback wrapper = [=](int error, GraphObject *result){
Vector<GraphScore *> scores;
if (error == 0) {
scores = result->getPropertyAsList<GraphScore>("data");
}
callback(error, scores);
};
request->setCallback(wrapper);
}
request->autorelease();
return request;
}
Request *Request::requestForMyScore(const ScoresRequestCallback &callback) {
Request *request = new Request("me/scores");
if (callback) {
RequestCallback wrapper = [=](int error, GraphObject *result){
Vector<GraphScore *> scores;
if (error == 0) {
scores = result->getPropertyAsList<GraphScore>("data");
}
callback(error, scores);
};
request->setCallback(wrapper);
}
request->autorelease();
return request;
}
Request *Request::requestForPostScore(long score, const PostScoreRequestCallback &callback) {
Request *request = new Request("me/scores");
request->setMethod(Method::POST);
if (callback) {
RequestCallback wrapper = [=](int error, GraphObject *result){
callback(error, !error);
};
request->setCallback(wrapper);
}
ValueMap params;
params["score"] = utils::StringUtils::toString(score);
request->setParams(params);
return request;
}
有什么建议吗?似乎是一个FB问题,但也许我做错了什么。