ShoeLace1291 Posted October 3, 2012 Share Posted October 3, 2012 I am trying to give my users the ability to share one of my articles on their facebook page, but I am having a few problems. I don't believe that the problem lies within my app, because it works perfectly in the example... there's just something wrong with my code. The getLoginUrl variable as an anchor just takes me back to the same exact page within my site, but it still tells me i'm not logged in. It never redirects me. This is the code I have so far: function facebook($article_id){ $config = array( 'appId' => '276870792431073', 'secret' => '8d49eee575413fb9a8063d22f65dbf6a' ); $this->load->library('facebook', $config); $user = $this->facebook->getUser(); if ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $this->facebook->api('/me'); } catch (FacebookApiException $e) { error_log($e); $user = null; } } if($user){ $article = $this->article->fetch_article($article_id); $config = array( 'message' => 'I just read an '.anchor('articles/'.url_title($article['title']).'/'.$article_id, 'article').' on '.anchor('', 'TrackTheOutbreak.com').'!', ); $this->facebook->api('/me/feed', 'post', $config); } else { $data['MESSAGE_TITLE'] = 'Authentication Error'; $data['MESSAGE_TEXT'] = 'You must be logged into an existing Facebook account to use this feature. Click '.anchor($this->facebook->getLoginUrl(), 'here').' to login.'; $this->parser->parse('error_body.tpl', $data); } } Quote Link to comment https://forums.phpfreaks.com/topic/269052-codeigniter-and-facebook-sdk/ Share on other sites More sharing options...
Mahngiel Posted October 5, 2012 Share Posted October 5, 2012 (edited) you have this: $user = $this->facebook->getUser(); , but you're not passing anything to the library to return with. How is that being populated? You're going to have to paste that library code. Oh, and you're going to want to change your API ID & secret, as it's likely already been cached by the search bots. Edited October 5, 2012 by Mahngiel Quote Link to comment https://forums.phpfreaks.com/topic/269052-codeigniter-and-facebook-sdk/#findComment-1382754 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.