Take the tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I look around this problem but I didn't found any answer to resolve my problem. I make Facebook login using Facebook JavaScript API, then I make a ajax request to post a photo in a group's wall, but, the PHP always return "Invalid OAuth access token signature." I made exactly like Facebook Documentation recomends. Look below:

   var fbAppId = "my_app_id";

    window.fbAsyncInit = function() {
      FB.init({
        appId: fbAppId,
        status: true,
        cookie: true,
        xfbml: true,
        oauth: true
      });

      FB.getLoginStatus(function(response) {
        if (response.status === "connected") {
          FB.api("/me", function(response) {
            $(".login-information").html("Olá, <span>" + response.name + "</span>").fadeIn();
            $("#content").fadeIn();
          })
        } else {
          $("#login").fadeIn();
        }
      });
    };

    (function(d, s, id){
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) {return;}
      js = d.createElement(s); js.id = id;
      js.src = "//connect.facebook.net/en_US/all.js";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));


    $("#login-button").click(function() {
      FB.login(function(response) {
        if (response.authResponse) {
          FB.api("/me", function(response) {
            $(".login-information").html("Olá, <span>" + response.name + "</span>").fadeIn();
            $("#login").slideUp(function() {
              $("#content").fadeIn();
            })
          })
        }
      }, {scope: "email,photo_upload,publish_actions,publish_stream,user_groups"})
    });

` include("components/fb_api/facebook.php");

    header("Content-Type: text/plain");

    $description = $_POST["description"];
    $price = $_POST["price"];
    $type = $_POST["type"];
    $photo = realpath(substr($_POST["photo"], 0, 14));

    $appId = "<my_app_id>";
    $appSecret = "<my_app_secret>";
    $groupId = "<my_group_id>";

    $post_url = "/$groupId/photos";

    $message = "$description\r\n";
    $message .= "\r\n$type\r\n";
    $message .= "\r\n$price\r\n";
    $message .= "\r\n---\r\n";
    $message .= "Posted using Compra e Venda publisher app for Facebook";

    $post_data = array(
      "message"=>$message,
      "source"=>"@$photo",
    );

    $fb = new Facebook(array(
      "appId"=>$appId,
      "appSecret"=>$appSecret,
      "fileUpload"=>true,
      "cookie"=>true
    ));

    try {
      $post = $fb->api($post_url, "post", $post_data);
    } catch(FacebookApiException $e) {
      die($e->getMessage()); // exception return the error
    }

The javascript works fine and I get login. But the PHP not recognize the login status and return me an error.

share|improve this question
1  
Oh Gosh! I'm sorry guys... I understand what's going wrong... "appSecret"=>$appSecret the correct is "secret"=>$appSecret –  Evandro Araújo Sep 26 at 11:26
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.