我使用parse-php-sdk.Now我需要我的客户使用twitter登录然后将它们添加为解析用户。因为没有功能我可以在ParseUser.php中用作twitter登录,所以我写了一个:
public static function logInWithTwitter($id, $access_token, $expiration_date = null)
{
if (!$id) {
throw new ParseException("Cannot log in twitter user without an id.");
}
if (!$access_token) {
throw new ParseException(
"Cannot log in twitter user without an access token."
);
}
if (!$expiration_date) {
$expiration_date = new \DateTime();
$expiration_date->setTimestamp(time() + 86400 * 60);
}
$data = json_encode(['authData' =>
["twitter" => [
"id" => $id, "access_token" => $access_token,
"expiration_date" => ParseClient::getProperDateFormat($expiration_date)
]]
]);
$result = ParseClient::_request("POST", "/1/users", "", $data);
$user = new ParseUser();
$user->_mergeAfterFetch($result);
$user->handleSaveResult(true);
ParseClient::getStorage()->set("user", $user);
return $user;
}
但是当我用twitter登录时,
error occurs: Code : 251 Message:Twitter credential verification failed.。我试图寻找解决方案,但我发现的只是应用程序平台问题,如果通过在TWSignedRequest中设置consumerKey和consumerSecret,它们可以解决。但我不知道是否需要设置twitter consumerKey和consumerSecret,如果我需要这样做,我应该在哪里设置?