首页 \ 问答 \ Facebook Graph API,扩展权限(Facebook Graph API, extended permissions)

Facebook Graph API,扩展权限(Facebook Graph API, extended permissions)

我正在尝试使用facebook Graph API来更新用户staus消息。

我在使用它时遇到以下错误,我认为新的图形sdk没有被正确引用?

Notice: Undefined property: Facebook::$api_client in /users/home/aafhe7vh/web/public/update.php  on line 9

Fatal error: Call to a member function users_hasAppPermission() on a non-object in /users/home/aafhe7vh/web/public/update.php on line 9

这是我正在使用的文件http://github.com/facebook/php-sdk/blob/master/src/facebook.php

以下是我的update.php的内容:


# <?php  

  include_once ('facebook.php');
  $api_key = '@@@@@@@@@@@@@@@@@@@2';
  $secret  = '$$$$$$$$$$$$$$$$$$$$44';
  global $facebook;
  $facebook = new Facebook($api_key, $secret);

# include_once("config.php");  
# if (!$facebook->api_client->users_hasAppPermission("status_update")){  
# echo '<fb:prompt-permission perms="status_update" next_fbjs="greet()">Let us update your status </fb:prompt-permission>';  
# $visibility = "none";  
# }  
# else  
# $visibility = "block";  
#   
# if(isset($_POST['hello']))  
# {  
#     $facebook->api_client->users_setStatus($_POST['hello']);  
#     echo "<p>Your status has been updated</p>";  
# }  
# ?>  
# <div id="statusdiv" style="display:<?=$visibility;?>;">  
#     <form method="POST">  
#         Please update your status:<br/>  
#         <input type="text" name="status" /> <br/>  
#         <input type="submit" value="change status" />  
#     </form>  
# </div>  
#   
# <script>  
# 
function greet()  
# {  
#     var session = "<?=$facebook->api_client->session_key;?>";  
#     document.getElementById("statusdiv").setStyle("display","block");  
#     new Dialog().showMessage("Info","Thank you for granting us this permission! ");  
# }  
</script>

我在这里使用了上面的代码, http://fbcookbook.ofhas.in/tag/extended-permission/

我不确定config.php应该包含什么,所以我在代码中删除了该行。

谢谢。


I am trying to use facebook Graph API, to update a users staus message.

I am getting the following error while using it, I think the new graph sdk is not being properly referenced ?

Notice: Undefined property: Facebook::$api_client in /users/home/aafhe7vh/web/public/update.php  on line 9

Fatal error: Call to a member function users_hasAppPermission() on a non-object in /users/home/aafhe7vh/web/public/update.php on line 9

This is the file I am using http://github.com/facebook/php-sdk/blob/master/src/facebook.php

Following is the content of my update.php:


# <?php  

  include_once ('facebook.php');
  $api_key = '@@@@@@@@@@@@@@@@@@@2';
  $secret  = '$$$$$$$$$$$$$$$$$$$$44';
  global $facebook;
  $facebook = new Facebook($api_key, $secret);

# include_once("config.php");  
# if (!$facebook->api_client->users_hasAppPermission("status_update")){  
# echo '<fb:prompt-permission perms="status_update" next_fbjs="greet()">Let us update your status </fb:prompt-permission>';  
# $visibility = "none";  
# }  
# else  
# $visibility = "block";  
#   
# if(isset($_POST['hello']))  
# {  
#     $facebook->api_client->users_setStatus($_POST['hello']);  
#     echo "<p>Your status has been updated</p>";  
# }  
# ?>  
# <div id="statusdiv" style="display:<?=$visibility;?>;">  
#     <form method="POST">  
#         Please update your status:<br/>  
#         <input type="text" name="status" /> <br/>  
#         <input type="submit" value="change status" />  
#     </form>  
# </div>  
#   
# <script>  
# 
function greet()  
# {  
#     var session = "<?=$facebook->api_client->session_key;?>";  
#     document.getElementById("statusdiv").setStyle("display","block");  
#     new Dialog().showMessage("Info","Thank you for granting us this permission! ");  
# }  
</script>

I used the above code from here , http://fbcookbook.ofhas.in/tag/extended-permission/

I am not sure what the config.php should contain so I have removed that line in my code.

Thanks.


原文:https://stackoverflow.com/questions/3112745
更新时间:2023-03-28 09:03

最满意答案

好吧,实际上我在我正在进行的项目中的BaseController中做了类似的事情:

public function smart_response($data, $redirect_to_route = null, $route_params = array())
{       
    if (Request::ajax())
    {
        return Response::json($data);
    }
    else
    {
        Alert::boolean($data['msg'], $data['success']);
        return is_null($redirect_to_route) ? Redirect::back() : Redirect::to_route($redirect_to_route, $route_params);
    }
}

我想你可以得到我的想法。

也许你也可以使用后期过滤器? 但我认为没有正确或错误的解决方案。


Well, in fact I did something similar in the BaseController in the project I'm working on:

public function smart_response($data, $redirect_to_route = null, $route_params = array())
{       
    if (Request::ajax())
    {
        return Response::json($data);
    }
    else
    {
        Alert::boolean($data['msg'], $data['success']);
        return is_null($redirect_to_route) ? Redirect::back() : Redirect::to_route($redirect_to_route, $route_params);
    }
}

I guess you can get my idea.

Maybe you could use a post filter too? But I don't think there is a right or wrong solution for this.

相关问答

更多
  • 我正在创业,我几乎有同样的问题需要解决。 我认为唯一的区别在于第一个问题,因为我决定仅将API访问权限限于经过身份验证的用户。 但是,这是我如何解决我的问题: 1.如何使我的API安全? 正如我写的,我仅将API访问权限限于已通过身份验证的用户。 我使用基于令牌的身份验证和基于以下软件包的自己的REST注册/身份验证API端点: Django的休息框架 Django的allauth 如果你想使用这个解决方案,我建议你也看一下django-rest-auth 。 2.如何使我的API快速高效? 如果您的“请求 ...
  • 好吧,实际上我在我正在进行的项目中的BaseController中做了类似的事情: public function smart_response($data, $redirect_to_route = null, $route_params = array()) { if (Request::ajax()) { return Response::json($data); } else { Alert::boolean($d ...
  • 对例外的回应 您可以通过处理App\Exceptions\Handler的异常来完成此操作。 你可以在render方法中使用它,喜欢: /** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $e * @return \Illuminate\Http\Response */ public function render ...
  • 根据Laravel错误日志,您的csrf令牌不匹配。 如果您正在构建API,您可能不希望使用“web”中间件。 该中间件组正在启动会话,并将检查所有未使用READ(GET,HEAD,OPTIONS)HTTP方法的请求上的csrf令牌。 默认情况下,Laravel会将routes.php中的所有路由放入路由组中,并在app\Providers中的RouteServiceProvider中加载“web”中间件(如果版本> = 5.2.27)。 根据Laravel错误日志,这可能就是从哪里开始的。 这可能会有所帮 ...
  • 是的,你可以使用这种方法: if( $request->wantsJson()){ return response()->json(['your response as json']) }else{ return view('....') } Yes you can using this approach: if( $request->wantsJson()){ return response()->json(['your response as json']) }else{ ...
  • 请始终使用中间件,并在API组列表中提及apis列表,如下所示 Route::group(['middleware' => 'auth:api'], function () { Route::get('getUser','Testcontroller@getData'); }); Always go with the middleware and mention the list of apis in the API group list as follows Route::group(['midd ...
  • 从你的问题,我得到以下内容: 我如何处理auth中间件...... 好吧,我们假设您有两个中间件auth.basic , auth.admin 然后你可以让你的路线像: Route::post('/api/getResponse', ['middleware' => 'auth', function () { $var = "you have access to this route"; return json_encode($var); }]); 在这里,您设置是否以及谁有权访问此特定路 ...
  • 我正在研究在Google的类似项目中使用流星的可行性分析,我认为Meteor对您的项目会很好。 管理员用户创建 - 检查休斯敦 REST API - [你自己的工具不需要一个](需要用流星术语思考)。 流星有一个更简单的机制 - Meteor.call和Meteor.methods 。 用户权限 - 请参阅角色包 文件处理 - 请参阅CollectionFS或搜索大气上传 。 外部API调用 - HTTP.get使其变得微不足道。 另请参阅特定包装的气氛。 大数据表格 - 查看关于表格小部件的答案 I'm ...
  • 无法直接重新排列数组,列表。 您可以创建一个包含数组和列表作为成员的类,并可以返回该类的对象。 注意:REST无法返回Array或List Retruning of Array,List is not possible directly. You can create a class with array and list as member and can return object of that class. N.B: REST cannot return Array or List
  • 如果客户端用于通过POST调用服务器(即HttpPost httppost = new HttpPost("http://www.yoursite.com/script.php");在android中)那么你将获得用户在$_POST发布的所有数据$_POST 如果你是初学者关于休息时间,请不要在这个级别搞乱数据库,只需创建页面 并从客户端调用它,你会得到更多的路径:) if client is using to call server ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)