Topic-icon FB.api Having Problem

Active Subscriptions:

None
11 years 11 months ago #45322 by farkab
FB.api Having Problem was created by farkab
Hi There,
I am using JFBCONNECT Version: 6.0.5 , I have not upgrade it yet as my App is made before April 30 , So I am still using Graph api v1.0 , Everything looks perfect so far until I try to publish a post through graph api with JAVASCRIPT not with PHP . I have a video .. When user finish to watch that video I call the following code through javascript .. but the response is Error..

var params = {};

params['link'] = 'http://mysiteurl.com';


  
FB.api('/me/feed', 'post', params, function(response) {
  if (!response || response.error) {
    alert('Error occured');
  } else {
    alert('Published to stream - you might want to delete it now!');
  }
});
      

I could publish the post with php ,but Javascript is having problem. but I like to post with javascript .. as Facebook dont like php to publish post that much.
The topic has been locked.
Support Specialist
11 years 11 months ago #45335 by alzander
Replied by alzander on topic FB.api Having Problem
First, JFBConnect v6.1.0 still supports Graph API v1.0 apps. We actually have that as the default app version with 2.0 available and working if your app must user 2.0. So you should be able to upgrade to JFBConnect v6.1.0 without any issues.

As for your posting problem, can you tell me:
* Does the sharing popup appear at all, or do you get an error right away?
* What is the actual error message you get?

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
11 years 11 months ago - 11 years 11 months ago #45375 by farkab
Replied by farkab on topic FB.api Having Problem
Thanks for your reply... Ok if I use JFBConnect v6.1.0 , Do I have to mention anywhere in configuration that I like to use graph api v1.0 or it will detect automatically depends on creation date of apps.


and For the first question after I use the following code , it's working
FB.login(function(){
        var body = 'Reading Connect JS documentation';

        FB.api('/me/feed', 'post', { body: body, message: 'My message is ...' }, function(response) {
          if (!response || response.error) {
            alert('Error occured');
          } else {
            alert('Post ID: ' + response);
          }
        });
    }, {});

But My question is user is already logged in .. then why I have to call FB.login again?
Last edit: 11 years 11 months ago by farkab.
The topic has been locked.
Support Specialist
11 years 11 months ago #45384 by alzander
Replied by alzander on topic FB.api Having Problem

Do I have to mention anywhere in configuration that I like to use graph api v1.0 or it will detect automatically depends on creation date of apps.

No. JFBConnect will use Graph API v1, if it's available for your App. If Graph API v1 isn't available, v2 will be used. I would recommend upgrading your calls to v2 wherever possible though, since it will make the transition easier. We're planning to support v1 apps until April of next year, when v2 becomes mandatory.

But My question is user is already logged in .. then why I have to call FB.login again?

I'm not sure. You never told me what the error you were receiving was before. If the user isn't detected by the Javascript, try setting the "Autologin Facebook Users" setting in the JFBConnect -> Facebook area to "Yes". Then try your code again.

The Auto-login feature has some extra Javascript that will check if the user is logged in on every page, and may ensure the code is setup properly before you try your feed call.

If that works, and you don't want the auto-login feature enabled, just let me know. There's a simple code change to leave it disabled, but still do the Javascript checks for logging the user in.

Thanks,
Alex
The topic has been locked.