本文介绍了如何使用PHP发布到Facebook页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我想使用PHP从我的网站发布到我自己的Facebook页面的墙上。 我有以下内容: Facebook应用程序 AppID,AppSecret,ApiKey Facebook页面 with PageID 我自己的Facebook帐户 - 我是上述申请和页面的管理员和创建者。 例如我写了一篇博客文章,我想在Facebook页面的墙上找到名字,简短描述和图片。或者我想每天自动在Facebook页面上发布一些文章作为一个cron工作。 你可以提供一个一步一步教程如何完成这个? 我已经阅读了关于Facebook登录的文章: https://developers.facebook.com/docs/facebook-login/ 但我还是不知道在我的代码中写什么。 更新1 这是我发送一个应用访问令牌的请求: $ url ='https://graph.facebook。 com / oauth / access_token?grant_type = client_credentials& client_id =' .Yii :: app() - > params ['FacebookAppID'] 。'& client_secret =' .Yii ::应用程序() - > PARAMS [ 'FacebookSecret']; 响应与此类似(假符号): access_token = 326584076429 | ax3-D39YbpDcR9rMRQn_fMvNu_s 什么 access_token 是吗?应用访问令牌?如何获取用户访问令牌? 我尝试使用这里的访问令牌: https://developers.facebook.com/tools/explorer?method=GET&path=me%2Faccounts 但是我收到以下错误信息: 必须使用活动的访问令牌来查询有关当前用户 那么我应该如何获得正确的访问令牌? 更新2: 如何在没有客户端交互的情况下在我的应用中获得正确的Facebook令牌? 我是管理员和Facebook应用程序的创建者和Facebook页面。 解决方案 一步一步 验证一个页面的用户admin(自己) 请求一个扩展访问令牌(获取一个60天的品种,因为offline_access不见了)。请参阅 https://developers.facebook.com/docs/offline-access-deprecation/ Call Graph API me / accounts 并搜索结果列表,找到您感兴趣的页面 从页面获取页面访问令牌,并开始使用它来发送呼叫 可能获取页面的扩展访问令牌访问令牌,如步骤2中所述,请尝试让我们知道是否可以进行页面访问令牌。 您可以在 https://developers.facebook.com/tools/explorer 上实验上述内容 快乐编码! 编辑 为了获得无任何用户对话的访问令牌,您可以使用 https://developers.facebook.com/tools/access_token/ 获取访问令牌。 I would like to post to my own Facebook page's wall from my website using PHP.I have the following:Facebook Application with AppID, AppSecret, ApiKeyFacebook Page with PageIDmy own Facebook account - I'm the admin and the creator of the application and page mentioned above.E.g. I write a blog post, and I'd like to get the name, the short description and a picture on my Facebook page's wall. Or I would like to publish some articles on the Facebook page every day automatically as a cron job.Could you provide a step-by-step tutorial how to accomplish this?I've read this article about Facebook Login:https://developers.facebook.com/docs/facebook-login/but I still don't know what to write in my code.UPDATE 1This is how I send a request for an App Access Token:$url = 'https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id=' .Yii::app()->params['FacebookAppID'] .'&client_secret=' .Yii::app()->params['FacebookSecret'];The response is similar to this (fake symbols):access_token=326584076429|ax3-D39YbpDcR9rMRQn_fMvNu_sWhat access_token is it? Application Access Token? How to get a User Access Token?I tried to use the access token from here:https://developers.facebook.com/tools/explorer?method=GET&path=me%2Faccountsbut I got the following error message: An active access token must be used to query information about the current userSo how should I obtain the right access token?UPDATE 2:How can I get the right Facebook tokens in my application without any client interaction?I'm the admin and the creator of the Facebook Application and the Facebook Page. 解决方案 Step by stepAuthenticate a user that is a page admin (yourself)Request an extended access token (to get a 60 day variety as offline_access is gone). See https://developers.facebook.com/docs/offline-access-deprecation/Call Graph API me/accounts and search thru the resulting list to find the page you're interested inTake the page access token from the page and start using that for the calls to postIt might be possible to get an extended access token for a page access token like described in step 2, please try and let us know if that can be done for page access token too.You can experiment with the above at https://developers.facebook.com/tools/explorerHappy Coding!EDITFor getting an access token without dialogs for any user, you can use https://developers.facebook.com/tools/access_token/ to get an access token. 这篇关于如何使用PHP发布到Facebook页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-19 02:21