Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Facebook provide Access Token for a user to use the Facebook app. For the First time , user has to login through facebook login, after login to the site, it will ask the permission to access the App. Once User Accept then facebook will return you a code throgh url. You have to take the code and use that to get access token</p> <p>by using following code</p> <pre><code>$url = "https://graph.facebook.com/oauth/access_token?client_id=". $yourappId ."&amp;redirect_uri=". urlencode($this-&gt;redirect_url) ."&amp;client_secret=". $youappsecret."&amp;code=". $code; $auth_token = $this-&gt;getContents($url); $str = explode('=',$auth_token); $token = explode('&amp;expires', $str[1]); </code></pre> <p>Here $token will have the access token of an user, u can store that token in ur local db and use that token to post a message to facebook wall. its simple.. thats all.</p> <p>To Post a message on Fb Wall</p> <pre><code>$fb_id = "User_fb_id" $access_token = "User_Access_Token_Take by Above code" $msg = "Message_to_post" $img_path = "Image_Path" $facebook = new Facebook(array( 'appId' =&gt; $this-&gt;appId, 'secret' =&gt; $this-&gt;secret, 'cookie' =&gt; true)); if($msg != NULL) { $attachment = array( 'message' =&gt; $msg, 'name' =&gt; 'NHM', 'picture' =&gt; $img_path); } try {$result = $facebook-&gt;api('/'. $fb_id . '/feed/', 'post', $attachment); if(isset($result['id'])) return true; else return false; } catch(FacebookApiException $e) { return $e-&gt;getMessage(); } </code></pre> <p>Here you have to user Facebook User Id. To get User Id use the following Code</p> <pre><code>$url = "https://graph.facebook.com/me?access_token=". $access_token; $userInfo = $this-&gt;getContents($url); $userInfo = json_decode($userInfo, true); public function getContents($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $content = curl_exec ($ch); curl_close ($ch); return $content; } </code></pre> <p>Try this . Let me know If any issues </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload