脚本宝典收集整理的这篇文章主要介绍了php – Facebook API:如何发布到自己的应用程序墙,没有登录,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
$fb = new FaceBook(array( 'appId' => 'appid','secret' => 'appsecret','cookie' => true )); if ($fb->getSession()) { // Post } else { // LOGger // Every time I get in here :( }
我需要做些什么才能使用脚本将其发布到我自己的应用程序墙上?
要发布到您的应用程序墙:
https://graph.facebook.com/oauth/access_token?
CLIENT_ID = YOUR_APP_ID&安培; client_secret = YOUR_APP_SECRET&安培;
grant_tyPE = client_credentials
2-发布到墙而不检查会话
示例:
<?PHP require_once 'facebook.PHP' //Function to Get Access Token function get_app_token($appid,$appsecret) { $args = array( 'grant_type' => 'client_credentials','client_id' => $appid,'client_secret' => $appsecret ); $ch = curl_init(); $url = 'https://graph.facebook.COM/oauth/access_token'; @R_777_223@($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_HEADER,false); curl_setopt($ch,CURLOPT_RETURNtransfer,true); curl_setopt($ch,CURLOPT_POST,CURLOPT_POSTFIELDS,$args); $data = curl_exec($ch); return json_encode($data); } // Create FB Object Instance $facebook = new Facebook(array( 'appId' => $appid,'secret' => $appsecret,'cookie' => false,)); //Get App Token $token = get_app_token($appid,$appsecret); //Try to Publish on wall or catch the Facebook exception try { $attachment = array('message' => '','access_token' => $token,'name' => 'Attachment Name','caption' => 'Attachment Caption','link' => 'http://apps.facebook.com/xxxxxx/','description' => 'Description .....','picture' => 'http://www.GOOGLE.com/logo.jpg','actions' => array(array('name' => 'Action Text','link' => 'http://apps.facebook.com/xxxxxx/')) ); $result = $facebook->api('/'.$appid.'/Feed/','post',$attachment); } //If the post is not published,PRint error details catch (FacebookApiException $e) { echo '<pre>'; print_r($e); echo '</pre>'; }
请查看本页面的APP LOgin部分以获取更多信息:
http://developers.facebook.com/docs/authentication/
以上是脚本宝典为你收集整理的php – Facebook API:如何发布到自己的应用程序墙,没有登录全部内容,希望文章能够帮你解决php – Facebook API:如何发布到自己的应用程序墙,没有登录所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。