我需要检查Facebook app
数据库中Facebook's
是否存在APP-ID
,APP-SECRET
和用户通过表单输入提供的$apid = $_POST['appid'];
$apsec = $_POST['appsec'];
$fb = new Facebook\Facebook([
'app_id' => $apid,
'app_secret' => $apsec,
'default_graph_version' => 'v2.5',
]);
try{
$appData=$fb->get('/'.$apid, $apid.'|'.$apsec);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
// When Graph returns an error
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
// When validation fails or other local issues
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$appData=$appData->getDecodedBody();
if(isset($appData)){
$_SESSION['app_name']=$appData['name'];
$_SESSION['app_image']=$appData['url'];
}else{
//should return some kind of error message
}
是否存在Graph API
。我尝试这样做:
try block
我想如果我从app access token
打电话给$accessToken = new Facebook\Authentication\AccessToken($apid.'|'.$apsec);
$check = $accessToken ->isAppAccessToken();
var_dump($check);
,它会返回某种错误信息或我可以使用的任何内容,但它会杀死整个脚本。然后,我想到只检查app-id
,我尝试了这个:
app-secret
但是对于任何随机插入的// Declared at the form level
private bool _modified = false;
public Form1()
{
InitializeComponent();
// This could be done in the form designer of course
// o repeated here for every textbox involved....
txtName.TextChanged += OnBoxesChanged;
......
}
private void Form1_Load(object sender, EventArgs e)
{
.....
// Code that initializes the textboxes could raise the TextChanged event
// So it is better to reset the global variable to an untouched state
_modified = false;
}
private void OnBoxesChanged(object sender, EventArgs e)
{
// Every textbox will call this event handler
_modified = true;
}
private void btnClose_Click(object sender, EventArgs e)
{
if(_modified)
{
// Save, warning, whatever in case of changes ....
}
}
和nodes
,它都会返回true,所以它并不真正检查app是否存在。如果你知道如何解决这个问题,请帮忙。