Note that there are some explanatory texts on larger screens.

plurals
  1. PODebug photo like system
    primarykey
    data
    text
    <p><strong>I have this error: Fatal error: Uncaught OAuthException: Invalid OAuth access token signature.</strong> </p> <p>I can't get the system (like button to do the like in a photo (page photo - no permissions require I guess) work.. Can somebody help me?</p> <p>test.php:</p> <pre><code> &lt;?php //include "dbc.php"; require './src/facebook.php'; $url = (!empty($_SERVER['HTTPS'])) ? 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'].$_SERVER['REQUEST_URL'] : 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'].$_SERVER['REQUEST_URL']; $facebook = new Facebook(array( 'appId' =&gt; '******', 'secret' =&gt; '******', 'cookie' =&gt; true, // enable optional cookie support )); $user = $facebook-&gt;getUser(); if ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook-&gt;api('/me'); //$pageInfo = $facebook-&gt;api('/'.$pageid.'?access_token='.$_SESSION['fb_112104298812138_access_token].'); //$pageInfoUser = $user_profile[id]; } catch (FacebookApiException $e) { error_log($e); $user = null; } } /* */ if ($user) { $logoutUrl = $facebook-&gt;getLogoutUrl(); } else { $params = array( scope =&gt; 'read_stream,publish_stream,publish_actions,offline_access', redirect_uri =&gt; $url ); $loginUrl = $facebook-&gt;getLoginUrl($params); } $access_token = $facebook-&gt;getAccessToken(); // $access_token = $_SESSION['user_id']; //$_SESSION['fb_135669679827333_access_token']; if(!$user){ echo ' : &lt;a href="'.$loginUrl.'" target="_self"&gt;Login&lt;/a&gt; '; }else{ echo '&lt;a href="'.$logoutUrl.'?'.$app_access_token.'" target="_blank"&gt;Logout&lt;/a&gt;'; } ?&gt; &lt;? function GetCH(){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://graph.facebook.com/oauth/access_token?client_id=112115512230132&amp;client_secret=ef3d2a30aa9a3f799130565b8391d42dT&amp;grant_type=client_credentials"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT_MS,20000); if(substr($url,0,8)=='https://'){ // The following ensures SSL always works. A little detail: // SSL does two things at once: // 1. it encrypts communication // 2. it ensures the target party is who it claims to be. // In short, if the following code is allowed, CURL won't check if the // certificate is known and valid, however, it still encrypts communication. curl_setopt($ch,CURLOPT_HTTPAUTH,CURLAUTH_ANY); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false); } $sendCH = curl_exec($ch); curl_close($ch); return $sendCH; }; echo "Access_token : ".$access_token; $app_access_token = GetCH(); if($_GET['postid']){ $postid = $_GET['postid']; echo "test1"; }else{ $postid = "ERROR";//'135669679827333_151602784936066'; } if($access_token){ echo "test2"; $pageLike = $facebook-&gt;api('/'.$postid.'/likes?access_token='.$access_token.'&amp;method=post', 'POST'); } ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; &lt;title&gt;Untitled Document&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <hr> <hr> <p><strong>Update from OP post, below:</strong></p> <p>I have changed my code,</p> <p>Now I have this code:</p> <pre><code> require_once './src/facebook.php'; class photo_liker { function __construct() { $this-&gt;facebook = new Facebook( array('appId' =&gt; fb_appID, 'secret' =&gt; fb_secret, 'fileUpload' =&gt; true, 'cookie' =&gt; true)); } function postPhotoLike($photoid) { try { $args = array('access_token' =&gt; $this-&gt;facebook-&gt;getAccessToken()); $upload_photo = $this-&gt;facebook-&gt;api('/' . $photoid . '/likes', 'post', $args); } catch (FacebookApiException $e) { var_dump($e); } } function login() { try { $uid = $this-&gt;facebook-&gt;getUser(); } catch (Exception $e) { var_dump($e); } if($uid) { try { $user = $this-&gt;facebook-&gt;api('/me'); } catch (Exception $e) { var_dump($e); } return true; } else { $login_url = $this-&gt;facebook-&gt;getLoginUrl(array('scope' =&gt; 'email,publish_stream')); ob_clean(); echo("&lt;script&gt;top.location.href='" . $login_url . "'&lt;/script&gt;"); exit ; } return false; } } $test = new photo_liker(); $test-&gt;login(); $test-&gt;postPhotoLike('103273136379847'); </code></pre> <p>I got the getUser() == 0... I read that is a bug of SDK 3.* .. how can I solve it?</p>
    singulars
    1. This table or related slice is empty.
    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. 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