gpt4 book ai didi

codeigniter - 如何通过 CodeIgniter 修复 facebook 中的 "Call to a member function getUser()"?

转载 作者:行者123 更新时间:2023-12-02 03:52:51 24 4
gpt4 key购买 nike

我在椅子上坐了 2 个小时,我找不到这有什么问题。我是 codeigniter 的新手,我只是第一次遇到这个错误。你们能帮帮我吗?任何帮助,将不胜感激。非常感谢...

****A PHP Error was encountered
Severity: Notice
Message: Undefined property: Facebook_model::$facebook
Filename: models/facebook_model.php
Line Number: 15
Fatal error: *Call to a member function getUser() on a non-object in C:\xampp\htdocs\hpbge\hpbge_files\system\hpbgestrong text_web_app\models\facebook_model.php on line 15*****


<?php

类 Facebook_model 扩展模型 {

public function get_user() {

$query = $this->facebook->getUser();


if ($query) {

$data['is_true'] = TRUE;

$data['facebook_uid'] = $query;

return $data;

} else {

$data['is_true'] = FALSE;

return $data;

}

}



function get_access_token() {

$query = $this->facebook->getAccessToken();



if ($query) {

$data['is_true'] = TRUE;

$data['access_token'] = $query;

return $data;

} else {

$data['is_true'] = FALSE;

return $data;

}

}



function get_api_secret() {

$query = $this->facebook->getApiSecret();



if ($query) {

$data['is_true'] = TRUE;

$data['api_secret'] = $query;

return $data;

} else {

$data['is_true'] = FALSE;

return $data;

}

}



function get_app_id() {

$query = $this->facebook->getApiSecret();



if ($query) {

$data['is_true'] = TRUE;

$data['app_id'] = $query;

return $data;

} else {

$data['is_true'] = FALSE;

return $data;

}

}



function get_logout_url() {

$query = $this->facebook->getLogoutUrl(array('next' => base_url()));



if ($query) {

$data['is_true'] = TRUE;

$data['logout_url'] = $query;

return $data;

} else {

$data['is_true'] = FALSE;

return $data;

}

}



function get_signed_request() {

$query = $this->facebook->getSignedRequest();



if ($query) {

$data['is_true'] = TRUE;

$data['signed_request'] = $query;

return $data;

} else {

$data['is_true'] = FALSE;

return $data;

}

}



function set_access_token($access_token) {

$query = $this->facebook->setAccessToken($access_token);



if ($query) {

$data['is_true'] = TRUE;

return $data;

} else {

$data['is_true'] = FALSE;

return $data;

}

}



function set_api_secret($app_secret) {

$query = $this->facebook->setApiSecret($app_secret);



if ($query) {

$data['is_true'] = TRUE;

return $data;

} else {

$data['is_true'] = FALSE;

return $data;

}

}



function set_app_id($app_id) {

$query = $this->facebook->setAppId($app_id);



if ($query) {

$data['is_true'] = TRUE;

return $data;

} else {

$data['is_true'] = FALSE;

return $data;

}

}



//function is formatted for the following

//https://graph.facebook.com/ID/CONNECTION_TYPE?access_token=123456

function get_facebook_object($object, $facebook_uid, $access_token) {

$fb_connect = curl_init();

curl_setopt($fb_connect, CURLOPT_URL, 'https://graph.facebook.com/'.$facebook_uid.'/'.$object.'?access_token='.$access_token);

curl_setopt($fb_connect, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($fb_connect);

curl_close($fb_connect);



$result = json_decode($output);



if (isset($result->error)) {

$data['is_true'] = FALSE;

$data['message'] = $result->error->message;

$data['type'] = $result->error->type;

$data['code'] = $result->error->code;



return $data;

} else {

$data['is_true'] = TRUE;

$data['data'] = $result->data;



return $data;

}

}

最佳答案

看来你还没有加载 facebook 库把这一行放在你的模型文件中

$this->load->library('facebook', array(
'appId' => 'YOUR_APP_ID',
'secret' => 'YOUR_APP_SECRET'
));

并确保您已将 facebook.php 和 base_facebook.php 放入应用程序下的库文件夹中。

关于codeigniter - 如何通过 CodeIgniter 修复 facebook 中的 "Call to a member function getUser()"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13735938/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com