PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, February 21, 2022

[FIXED] Can I use both PHP and JavaScript Facebook APIs?

 February 21, 2022     facebook-graph-api, facebook-javascript-sdk, facebook-php-sdk, javascript, php     No comments   

Issue

I want to provide logging with facebook on my webpage. How can I use both APIs to get some facebook user info using PHP in one place and JS in other place? This is link to offical php sdk example usage (together with JS sdk):

https://github.com/facebook/php-sdk/blob/master/examples/with_js_sdk.php

What i want to do is to use somewhere in that file this code for example:

FB.api("/me", function (response) {
      alert('Name is ' + response.name);
});

or other JS sdk code to get some user info.

I always have a problem that when I use one type of logging in (PHP or JS) I can use only one kind of api to call for info. I don't know how to provide logging in which will make available both APIs. Someone knows how to do it? Thanks for help!


Solution

you can just using the php sdk at the same time still can you js api, in your script, just add this in your html body ,

<div id="fb-root"></div>
<script type="text/javascript" src="https://connect.facebook.net/en_US/all.js"></script>
 <script type="text/javascript">
   FB.init({
     appId  : '<?=$yourappid?>',
     status : true, 
     cookie : true, 
     xfbml  : true  
   });
 </script>

and try call call this

<script type="text/javascript">    
FB.api("/me", function (response) {
          alert('Name is ' + response.name);
    });
</script>

anyone pls correct me if i'm wrong



Answered By - Suriyanti Panagen
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing