Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [inne][php] problem z aplikacją na facebooka
-poziomka665-
post
Post #1





Goście







Ktoś tutaj dobrze ogarnia aplikacje na facebooku? Mogę trochę zapłacić za pomoc w procesie tworzenia mojej własnej aplikacji.
Dostaje taki error:
Kod
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/dyzimier/domains/bon-kfc.pl/public_html/index.php on line 56

Co może być źle? Myślę że to jakiś problem z pobieraniem danych użytkownika z facebooka, może problem z pozwoleniem?
Kod
<?php
session_start();



mysql_connect('localhost', 'dyzimier_appdmin', 'senso');
mysql_select_db('dyzimier_app');

# require library
require("facebook.php");

# Creating the facebook object
$facebook = new Facebook(array(
            'appId' => '390689170979338',
            'secret' => 'e3b443a146c28a25bdbdc5da71bbbb8e',
            'cookie' => true
        ));

# check active session
$session = $facebook->getUser();


if (!empty($session)) {
    # session active, get user id (getUser()) and user info (api->('/me'))
try {
        $uid = $facebook->getUser();
        $fb_access_token=$session['access_token'];
$params = array(
  'scope' => 'status_update,publish_stream',
  'redirect_url' => 'https://www.bon-kfc.pl/'
);
$Url = $facebook->getLoginUrl($params);
        $user = $facebook->api('/me');
        $photolink = 'http://graph.facebook.com/'.$user['id'].'/picture?type=square';
        $param = array(
            'method' => 'users.getInfo',
            'uids' => uid,
            'fields' => 'pic_big'
        );
        $users_getinfo = $facebook->api($param);
} catch (Exception $e) {

    }
    

    if (!empty($user)) {
        # active session, check if already registered the user
        $query = mysql_query("SELECT * FROM users WHERE oauth_provider = 'facebook' AND oauth_uid = " . $user['id']);
        $result = mysql_fetch_array($query);


        # If not, add it to the database
        if (empty($result)) {
           $query = mysql_query("INSERT INTO users (oauth_uid, oauth_provider, username, first_name, last_name, email, pic_square) VALUES ('facebook', {$user['id']}, '{$user['name']}', '{$user['first_name']}', '{$user['last_name']}','{$user['email']}', '".$photolink."')");
            $query = mysql_query("SELECT * FROM users WHERE id = " . mysql_insert_id());
            $result = mysql_fetch_array($query);
        }


        // variables in the session
        $_SESSION['id'] = $result['id'];
        $_SESSION['oauth_uid'] = $result['oauth_uid'];
        $_SESSION['oauth_provider'] = $result['oauth_provider'];
        $_SESSION['username'] = $result['username'];
    } else {
        # if error, kill the script
        die("There was an error.");
    }


} else {
$params = array(
  'scope' => 'status_update,publish_stream',
  'redirect_url' => 'https://www.bon-kfc.pl/'
);
    # no active session, generate one
    $login_url = $facebook->getLoginUrl($params);
    header("Location: " . $login_url);
}

?>

Proszę o szybką pomoc. Mój skype to Rasacz
Mam kilka pomysłów na aplikacje a jeśli pomożesz mi je stworzyć to będziesz miał w tym swój zysk.
Pozdrawiam
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
-poziomek-
post
Post #2





Goście







Oto kod:
  1. <?php
  2.  
  3.  
  4.  
  5. mysql_connect('localhost', 'dyzimier_appdmin', 'senso');
  6. mysql_select_db('dyzimier_app');
  7.  
  8. # require library
  9. require("facebook.php");
  10.  
  11. # Creating the facebook object
  12. $facebook = new Facebook(array(
  13. 'appId' => '390689170979338',
  14. 'secret' => 'e3b443a146c28a25bdbdc5da71bbbb8e',
  15. 'cookie' => true
  16. ));
  17.  
  18. # check active session
  19. $session = $facebook->getUser();
  20.  
  21.  
  22. if (!empty($session)) {
  23. # session active, get user id (getUser()) and user info (api->('/me'))
  24. try {
  25. $uid = $facebook->getUser();
  26. $fb_access_token=$session['access_token'];
  27. $params = array(
  28. 'scope' => 'status_update,publish_stream',
  29. 'redirect_url' => 'https://www.bon-kfc.pl/'
  30. );
  31. $Url = $facebook->getLoginUrl($params);
  32. $user = $facebook->api('/me');
  33. $photolink = 'http://graph.facebook.com/'.$user['id'].'/picture?type=square';
  34. $param = array(
  35. 'method' => 'users.getInfo',
  36. 'uids' => uid,
  37. 'fields' => 'pic_big'
  38. );
  39. $users_getinfo = $facebook->api($param);
  40. } catch (Exception $e) {
  41.  
  42. }
  43.  
  44.  
  45. if (!empty($user)) {
  46. # active session, check if already registered the user
  47. $query = mysql_query("SELECT * FROM users WHERE oauth_provider = 'facebook' AND oauth_uid = " . $user['id']);
  48. $result = mysql_fetch_array($query);
  49.  
  50.  
  51. # If not, add it to the database
  52. if (empty($result)) {
  53. $query = mysql_query("INSERT INTO users (oauth_uid, oauth_provider, username, first_name, last_name, email, pic_square) VALUES ('facebook', {$user['id']}, '{$user['name']}', '{$user['first_name']}', '{$user['last_name']}','{$user['email']}', '".$photolink."')");
  54. $query = mysql_query("SELECT * FROM users WHERE id = " . mysql_insert_id());
  55. $result = mysql_fetch_array($query);
  56. }
  57.  
  58.  
  59. // variables in the session
  60. $_SESSION['id'] = $result['id'];
  61. $_SESSION['oauth_uid'] = $result['oauth_uid'];
  62. $_SESSION['oauth_provider'] = $result['oauth_provider'];
  63. $_SESSION['username'] = $result['username'];
  64. } else {
  65. # if error, kill the script
  66. die("There was an error.");
  67. }
  68.  
  69.  
  70. } else {
  71. $params = array(
  72. 'scope' => 'status_update,publish_stream',
  73. 'redirect_url' => 'https://www.bon-kfc.pl/'
  74. );
  75. # no active session, generate one
  76. $login_url = $facebook->getLoginUrl($params);
  77. header("Location: " . $login_url);
  78. }
  79.  
  80. ?>

Nikt nie chce zarobić za pomoc? (IMG:style_emoticons/default/sad.gif)
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 2.10.2025 - 23:26