Beispiel #1
0
 public function testLoginStatusURLCustom()
 {
     $_SERVER['HTTP_HOST'] = 'fbrell.com';
     $_SERVER['REQUEST_URI'] = '/examples';
     $facebook = new Facebook(array('appId' => self::APP_ID, 'secret' => self::SECRET));
     $encodedUrl1 = rawurlencode('http://fbrell.com/examples');
     $okUrl = 'http://fbrell.com/here1';
     $encodedUrl2 = rawurlencode($okUrl);
     $loginStatusUrl = $facebook->getLoginStatusUrl(array('ok_session' => $okUrl));
     $this->assertNotNull(strpos($loginStatusUrl, $encodedUrl1), 'Expect the current url to exist.');
     $this->assertNotNull(strpos($loginStatusUrl, $encodedUrl2), 'Expect the custom url to exist.');
     unset($_SERVER['HTTP_HOST']);
     unset($_SERVER['REQUEST_URI']);
 }
Beispiel #2
0
// Facebook, but we don't know if the access token is valid. An access
// token is invalid if the user logged out of Facebook.
if ($user) {
    try {
        // Proceed knowing you have a logged in user who's authenticated.
        $user_profile = $facebook->api('/me');
    } catch (FacebookApiException $e) {
        error_log($e);
        $user = null;
    }
}
// Login or logout url will be needed depending on current user state.
if ($user) {
    $logoutUrl = $facebook->getLogoutUrl();
} else {
    $statusUrl = $facebook->getLoginStatusUrl();
    $loginUrl = $facebook->getLoginUrl();
}
// This call will always work since we are fetching public data.
$naitik = $facebook->api('/naitik');
?>
<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
    <title>php-sdk</title>
    <style>
        body {
            font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
        }

        h1 a {
Beispiel #3
0
    public function social_site_login($type)
    {
        $article = new postarticle();
        $image = new resizeImage();
        switch ($type) {
            case 'facebook':
                ?>


						<div id="fb-root"></div> 

						    <script src="http://connect.facebook.net/en_US/all.js"></script>  
						    <script> 
							    FB.init({ 
							      appId: '528594163842974', 
							      cookie: true,
							      status: true, 
							      xfbml: true 
							    }); 
						    </script>    

					        <?php 
                /** 
                 * Copyright 2011 Facebook, Inc.
                 *
                 * Licensed under the Apache License, Version 2.0 (the "License"); you may
                 * not use this file except in compliance with the License. You may obtain
                 * a copy of the License at
                 *
                 *     http://www.apache.org/licenses/LICENSE-2.0
                 *
                 * Unless required by applicable law or agreed to in writing, software
                 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
                 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
                 * License for the specific language governing permissions and limitations
                 * under the License.
                 * get friend list: https://developers.facebook.com/docs/graph-api/reference/user/friendlists/
                 */
                if ($mno != 136) {
                    // already logged in and redirecting to authenticate the account.
                    // echo " mno $mno <br>";
                    // $_SESSION['temp_mno'] = intval($mno);
                    // $this->go( 'login-authentication' );
                } else {
                    require '../../../fs_folders/API/facebook-php-sdk-master/src/facebook.php';
                    $facebook = new Facebook(array('appId' => '528594163842974', 'secret' => 'a411c8a3c4361556491b2c2ddf38bf21'));
                    $user = $facebook->getUser();
                    if ($user) {
                        try {
                            // $user_profile = $facebook->api('/me');
                            echo "user logon!";
                        } catch (FacebookApiException $e) {
                            error_log($e);
                            $user = null;
                            echo "user logout!";
                        }
                    }
                    if ($user) {
                        // echo " logout user";
                        $logoutUrl = $facebook->getLogoutUrl();
                    } else {
                        echo " set parametter to login ";
                        /*
                        								        $params = array(
                        								            'scope' =>'ads_management,create_event,create_note,email,export_stream,friends_about_me, 
                        								            	friends_activities, friends_birthday, friends_checkins, friends_education_history, friends_events, 
                        								            	friends_games_activity, friends_groups, friends_hometown, friends_interests, 
                        								            	friends_likes, friends_location, friends_notes, friends_online_presence, 
                        								            	friends_photo_video_tags, friends_photos, friends_questions, friends_relationship_details
                        								            	friends_relationships, friends_religion_politics, friends_status, friends_subscriptions
                        								            	friends_videos, friends_website, friends_work_history, manage_friendlists
                        								            	manage_notifications, manage_pages, offline_access, photo_upload, publish_actions
                        								            	publish_checkins, publish_stream, read_friendlists, read_insights, read_mailbox
                        								            	read_requests, read_stream, rsvp_event, share_item, sms, status_update, user_about_me
                        								            	user_activities, user_birthday, user_checkins, user_education_history, user_events
                        								            	user_games_activity, user_groups, user_hometown, user_interests, user_likes
                        								            	user_location, user_notes, user_online_presence, user_photo_video_tags, user_photos
                        								            	user_questions, user_relationship_details, user_relationships, user_religion_politics
                        								            	user_status, user_subscriptions, user_videos, user_website, user_work_history
                        								            	video_upload xmpp_login', 
                        								            	'redirect_uri' => 'http://fashionsponge.com/login'
                        								        );
                        */
                        $params = array('scope' => ' email,friends_about_me,user_about_me,user_birthday, user_education_history,
							            	user_games_activity, user_groups, user_hometown, user_interests, user_likes
							            	user_location, user_notes, user_online_presence, user_photo_video_tags, user_photos
							            	user_questions, user_relationship_details, user_relationships, user_religion_politics
							            	user_status, user_subscriptions, user_videos, user_website, user_work_history
							            	', 'redirect_uri' => 'http://fashionsponge.com/login');
                        $statusUrl = $facebook->getLoginStatusUrl();
                        $loginUrl = $facebook->getLoginUrl($params);
                    }
                }
                ?>
 

					        <!doctype html>
					        <html xmlns:fb="http://www.facebook.com/2008/fbml">
					          <head> 
					            <title>php-sdk FS-LogIN</title> 
					          	</head>
					          	<body>
						          	<?php 
                echo " <br> user =  {$user} <br> ";
                // echo " <br> user= "******" facebook user logon.";
                    echo " \n\t\t\t\t\t\t\t\t\t\t\t\t<a href='{$logoutUrl}'; >facebook Logout</a>\n\t\t\t\t\t\t\t\t\t\t        <a href='logout.php'>fs Logout</a> <br> \n\t\t\t\t\t\t\t\t\t\t    ";
                    echo " <h4> user facebook user logon info. </h4>";
                    echo '<pre>';
                    print_r($user_profile);
                    echo '</pre>';
                    #saving to account info and user info.
                    // echo "<hr>";
                    // freinds
                    /*
                    													echo " <h4> user facebook user logon friends. </h4>";
                    	print_r($friends);   
                    */
                    // sign up of get mno
                    $fs_user = selectV1('*', 'fs_members', array('fbid' => intval($user_profile['id'])));
                    $mno1 = $fs_user[0]['mno'];
                    if (!empty($mno1)) {
                        #allready a members
                        echo " 1.) fb user is already a member <br>";
                        echo " 2.) update all friends , friends in fs and friends in fb <br> ";
                        $fb_friends = $this->get_logging_in_fb_friends_and_filter($friends['data']);
                        $this->update_logging_in_fb_friends($mno1, $fb_friends['fb_all_freinds'], $fb_friends['fb_freinds_on_fs'], $fb_friends['fb_freinds_on_fb']);
                        $_SESSION['temp_mno'] = $mno1;
                        $this->go('login-authentication');
                    } else {
                        #new member
                        echo " 1.) fb user is a new member <br> ";
                        echo " 2.) add new info member to fashionsponge database [done] <br> ";
                        echo " 2.) add new account member to fashionsponge database [done] <br> ";
                        echo " 3.) update all friends , friends in fs and friends in fb [done] <br> ";
                        echo " 4.) get new profile pic from fb and save to fs [done]  <br> ";
                        echo " 5.) add activity action that new fs member joind and post it on the feed with the profile pic [done] <br> ";
                        echo " 6.) show profile information fields to fill up <br> ";
                        echo " 7.) show suggested brand  <br> ";
                        echo " 8.) show suggested member according to its style generated through the brands selected  <br> ";
                        echo " 9.) a welcome fashionsponge message sent to email <br> ";
                        // fb info
                        $fbid = $user_profile['id'];
                        $firstname = $user_profile['first_name'];
                        $lastname = $user_profile['last_name'];
                        $gender = $user_profile['gender'];
                        $birthday = substr($user_profile['birthday'], strlen($user_profile['birthday']) - 4, strlen($user_profile['birthday']));
                        $bio = $user_profile['bio'];
                        $workwith = $user_profile['work'][0]['position']['name'];
                        $workat = $user_profile['work'][0]['location']['name'];
                        $email = $user_profile['email'];
                        $username = str_replace('.', '', $user_profile['username']);
                        $username = str_replace('and', '', $username);
                        echo " <br><BR> FB INFO <br><BR><BR><BR>";
                        // education
                        $school_ex_len = count($user_profile['education']) - 1;
                        echo " total school expeience {$school_ex_len} <br> ";
                        # college
                        $studied_with = $user_profile['education'][$school_ex_len]['concentration'][0]['name'];
                        $studied_at = $user_profile['education'][$school_ex_len]['school']['name'];
                        $studied_graduate_date = $user_profile['education'][$school_ex_len]['year']['name'];
                        if (empty($studied_at)) {
                            # high school
                            $studied_at = $user_profile['education'][$school_ex_len - 1]['school']['name'];
                            $studied_graduate_date = $user_profile['education'][$school_ex_len - 1]['year']['name'];
                        }
                        echo " \t\t\t\t\t\t\t\t\t\t\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfbid = {$fbid}      <br> \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfirstname = {$firstname}  <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlastname = {$lastname}   <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tgender = {$gender}    <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbirthday = {$birthday}  <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbio = {$bio}       <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twork = {$work}          <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tworkat = {$workat}        <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tstudied_with = {$studied_with}   <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tstudied_at = {$studied_at}     <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tstudied_graduate_date = {$studied_graduate_date} <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\temail = {$email}    <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tusername = {$username}   <br><br><br><br><br><br> ";
                        /*
                        	$fbid = 100000954625049; 
                        	$firstname = 'Mary';
                        	$nickname  = 'Jean'; 
                        	$lastname = 'Suarez';   
                        */
                        // insert new user info .
                        $b = insert('fs_members', array('firstname', 'nickname', 'lastname', 'fbid', 'aboutme', 'bdate', 'gender', 'work_at', 'occupation', 'studied_at', 'studied_with', 'studied_graduate_date', 'datejoined'), array($firstname, $nickname, $lastname, $fbid, $bio, $birthday, $gender, $workat, $workwith, $studied_at, $studied_with, $studied_graduate_date, date("Y-m-d H:i:s")), 'mno');
                        // get new user info inserted
                        $userinfo = $this->get_latest_user_info();
                        $mno = intval($userinfo[0]['mno']);
                        // $email     = '*****@*****.**';
                        // $username  = '******';
                        // $pass      = '';
                        // insert new user account
                        $b = insert('fs_member_accounts', array('mno', 'email', 'username', 'pass'), array($mno, $email, $username, ''), 'mano');
                        // echo " new member <br>";
                        // $fs_user = selectV1('*','fs_members', array('fbid'=> intval($fbid) ) );
                        $fs_user = selectV1('*', 'fs_members', null, 'order by mno desc', 'limit 1');
                        $mno1 = intval($fs_user[0]['mno']);
                        $fb_friends = $this->get_logging_in_fb_friends_and_filter($friends['data']);
                        $this->update_logging_in_fb_friends($mno1, $fb_friends['fb_all_freinds'], $fb_friends['fb_freinds_on_fs'], $fb_friends['fb_freinds_on_fb']);
                        echo " big profile pic <br> ";
                        $size = 'large';
                        $url = "http://graph.facebook.com/{$fbid}/picture?type={$size}";
                        $headers = get_headers($url, 1);
                        if (isset($headers['Location'])) {
                            $bigpicurl = $headers['Location'];
                            // string
                        } else {
                            echo "ERROR";
                        }
                        echo "profile pic path src. {$bigpicurl} <br>";
                        echo "<img src=\"{$bigpicurl}\"  />";
                        // download from fb photo server
                        $mppno = $this->member_profile_pic_query(array('mno' => $mno1, 'action' => 'Joined', 'type' => 'insert-new-profile-pic-db'));
                        echo " your new profile pic in {$mppno} <br>";
                        $article->download_image_from_other_site($mppno, $bigpicurl, 'fs_folders/images/uploads/members/mem_original/');
                        /*
                        									                                	$profile_fs_src_original   = 'fs_folders/images/uploads/members/mem_original';
                        									                                	$profile_fs_src_thumbnail  = 'fs_folders/images/uploads/members/mem_thumnails'; 
                        									                                	$profile_fs_src_profilepic = 'fs_folders/images/uploads/members/mem_profile';  
                        */
                        // resize the profile pic downloaded
                        $this->resize_profile_pic_thumbnail_and_profile($mppno);
                        // $this->resize_fb_profile_pic( $mno1 , $image , $profile_fs_src_original , $profile_fs_src_thumbnail , $profile_fs_src_profilepic );
                        // add activity post feed
                        $this->add_activity_wall_post($mno1, $mppno, 'Joined', 'fs_members', $this->date_time);
                        // redirect to the main page
                        $_SESSION['type'] = 'new-member-fb-login';
                        $_SESSION['temp_mno'] = $mno1;
                        $_SESSION['lastpagevisited'] = 'profile_crop_display.php';
                        $this->go('login-authentication');
                    }
                    echo " ur mno {$mno1} <br> ";
                    // add update friends on fb and on fs
                    // updated
                    #saving to fb_all_friends , fb_friends_on_fs , fb_friends on fb at [ user account info ]
                    // echo "<hr>";
                } else {
                    // $b = updateArray('fs_members',array('fb_all_freinds'), array('505457421-+-549151146-+-'),'mno',$mno);
                    // if ($b) {
                    // 	echo " succesfully updated <br> ";
                    // }else{
                    // 	echo " failled to update ";
                    // }
                    echo "  \n\t\t\t\t\t\t\t\t                <a href='{$loginUrl}'>Login with Facebook</a> \n\t\t\t\t\t\t\t\t            ";
                    // $name = $this->get_facebook_user_info_by_fbid( $facebook , '100004690904448' );
                    // echo " fbid = 100004690904448 and name = $name <br>";
                }
                ?>
 
					          	</body>
					        </html>  
							<?php 
                break;
            case 'twitter':
                # code...
                break;
            case 'google':
                # code...
                break;
            case 'tumblr':
                # code...
                break;
            default:
                # code...
                break;
        }
    }
$user = $facebook->getUser();
if ($user) {
    try {
    } catch (FacebookApiException $e) {
        error_log($e);
        $user = null;
    }
}
if ($user) {
    $logoutUrl = $facebook->getLogoutUrl();
} else {
    $loginUrl = $facebook->getLoginUrl(array('scope' => 'email'));
}
$profile = $facebook->api('/me?scope=email');
$params = array('ok_session' => 'A', 'no_user' => 'B', 'no_session' => 'C');
$url_is_log = $facebook->getLoginStatusUrl($params);
?>
<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
	<head>
		<title>php-sdk</title>
		<style>
			body {
				font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
			}
			h1 a {
				text-decoration: none;
				color: #3b5998;
			}
			h1 a:hover {
				text-decoration: underline;
Beispiel #5
0
    function fblogin( $fb_friends_in_fs ) {?>
      
                 





        <?php
        /** 
         * Copyright 2011 Facebook, Inc.
         *
         * Licensed under the Apache License, Version 2.0 (the "License"); you may
         * not use this file except in compliance with the License. You may obtain
         * a copy of the License at
         *
         *     http://www.apache.org/licenses/LICENSE-2.0
         *
         * Unless required by applicable law or agreed to in writing, software
         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
         * License for the specific language governing permissions and limitations
         * under the License.
         * get friend list: https://developers.facebook.com/docs/graph-api/reference/user/friendlists/
         */

          require 'fs_folders/API/facebook-php-sdk-master/src/facebook.php';

        // Create our Application instance (replace this with your appId and secret).
        $facebook = new Facebook(array(
          'appId'  => '528594163842974',
          'secret' => 'a411c8a3c4361556491b2c2ddf38bf21',
        )); 

        // Get User ID
        $user = $facebook->getUser(); 
        // We may or may not have this data based on whether the user is logged in.
        //
        // If we have a $user id here, it means we know the user is logged into
        // Facebook, but we don't know if the access token is valid. An access
        // token is invalid if the user logged out of Facebook.

        if ($user) {
          try {
            // Proceed knowing you have a logged in user who's authenticated.
            $user_profile = $facebook->api('/me');
            echo "user logon!";
          } catch (FacebookApiException $e) {
            error_log($e);
            $user = null;
            echo "user logout!";
          }
        }

        // Login or logout url will be needed depending on current user state.
        if ($user) {
          $logoutUrl = $facebook->getLogoutUrl(); 
        } else {


          $params = array(
            'scope' =>'ads_management,create_event,create_note,email,export_stream,friends_about_me, 
              friends_activities, friends_birthday, friends_checkins, friends_education_history, friends_events, 
              friends_games_activity, friends_groups, friends_hometown, friends_interests, 
              friends_likes, friends_location, friends_notes, friends_online_presence, 
              friends_photo_video_tags, friends_photos, friends_questions, friends_relationship_details
              friends_relationships, friends_religion_politics, friends_status, friends_subscriptions
              friends_videos, friends_website, friends_work_history, manage_friendlists
              manage_notifications, manage_pages, offline_access, photo_upload, publish_actions
              publish_checkins, publish_stream, read_friendlists, read_insights, read_mailbox
              read_requests, read_stream, rsvp_event, share_item, sms, status_update, user_about_me
              user_activities, user_birthday, user_checkins, user_education_history, user_events
              user_games_activity, user_groups, user_hometown, user_interests, user_likes
              user_location, user_notes, user_online_presence, user_photo_video_tags, user_photos
              user_questions, user_relationship_details, user_relationships, user_religion_politics
              user_status, user_subscriptions, user_videos, user_website, user_work_history
              video_upload xmpp_login', 
            'redirect_uri' => 'http://fashionsponge.com/testPage.php'
          );




          $statusUrl = $facebook->getLoginStatusUrl();
          $loginUrl = $facebook->getLoginUrl($params);
            /* make the API call */
         echo " not login";
        /* handle the result */
        } 
        // This call will always work since we are fetching public data.
        $naitik = $facebook->api('/naitik');

        ?>
        <!doctype html>
        <html xmlns:fb="http://www.facebook.com/2008/fbml">
          <head>
            <title>php-sdk</title>
            <style>
              body {
                font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
              }
              h1 a {
                text-decoration: none;
                color: #3b5998;
              }
              h1 a:hover {
                text-decoration: underline;
              }
            </style>
          </head>
          <body>
            <h1>php-sdk</h1> 
            <?php if ($user): ?>
              <a href="<?php echo $logoutUrl; ?>">Logout</a>
              <a href="logout.php">Logout</a>
            <?php else: ?>
              <div>
                Check the login status using OAuth 2.0 handled by the PHP SDK:
                <a href="<?php echo $statusUrl; ?>">Check the login status</a>
              </div>
              <div>
                Login using OAuth 2.0 handled by the PHP SDK:
                <a href="<?php echo $loginUrl; ?>">Login with Facebook</a>
              </div>
            <?php endif ?>

            <h3>PHP Session</h3>
            <pre><?php print_r($_SESSION); ?></pre> 
            <?php if ($user): 
            ?>
              <h3>You</h3>
              <img src="https://graph.facebook.com/<?php echo $user; ?>/picture"> 
              <h3>Your User Object (/me)</h3>
              <pre><?php 
                    

                    print_r($user_profile); 

                ?></pre>
              

                <h1> scope  </h1>

                <?php 

                    echo 'email = '.$user_profile['email']."<br>";
                     
                ?>
         <?php 
              // $friendlistsGroup = $facebook->api('/me/friends');
            
            echo "<h1> friend list group </h1>";
            // print_r( $friendlistsGroup);

             // $user_profile = $facebook->api('/me');
              $friends = $facebook->api('/me/friends');
 

                // $fb_friends_in_fs = array(505457421,549151146 ,549294216 ,553913643 ); 
                // echo "<br> fb friends on fs <br>";
                // print_r($fb_friends_in_fs)
                // echo "<br> fb friends on facebook not yet on fs  <br>";
                // print_r($fb_friends_in_fs); 
              /*

                echo "<br><br> array <br>";
                  print_r($friends['data']);


*/

                  echo " <br><br> not array text";


                $frnds = $friends['data'];
                for ($i=0; $i < count($friends['data']) ; $i++) { 
                    $fb_all_freinds .=$frnds[$i]["id"]."kjl".$frnds[$i]["name"]."kjl";
                } 




                // echo "  $fb_all_freinds <br><br><br><br>";
                $mno = 133;   

             $b = mysql_query(" UPDATE fs_members SET fb_all_freinds = 'jesus erwin suarez gwapo kaau.'  WHERE mno = $mno ");
              if ($b) {
                echo " updated ";
              }else{
                echo " not updated ";
              } 



                echo " total friends are = ".count($friends['data'])."<br>";
                  echo '<ul>';
                  $c=0;
                  foreach ($friends["data"] as $value) {
                    $c++; 
                    if ( $c < 10 ) {
                        $fbfid = $value["id"];
                        if ( in_array($fbfid, $fb_friends_in_fs)) { 


                              echo '<li>';
                                echo " <h4> friend is on fashionsponge </h4>";
                                echo '<div class="pic">';
                                echo '<img src="https://graph.facebook.com/' . $value["id"] . '/picture"/>';
                                echo '</div>';
                                echo '<div class="picName">'.$value["name"].'</div>'; 
                                echo '<div class="picName">'.print_r($value).'</div>'; 
                                echo '</li>';   
                                 echo "<hr>";
                        }else{
                              echo '<li>';
                               echo " <h4> friend is on facebook </h4>";
                              echo '<div class="pic">';
                              echo  "<img src='https://graph.facebook.com/$fbfid/picture'/>";
 
                              
                                #big profile pic. 
                                $size = 'large';
                                $url = "http://graph.facebook.com/$fbfid/picture?type=$size"; 
                                $headers = get_headers($url, 1); 
                                if( isset($headers['Location']) ){  
                                    $bigpicurl = $headers['Location']; // string
                                }else{
                                    echo "ERROR";
                                } 
                                echo "<img src=\"$bigpicurl\"  />"; 

                                


                              echo '</div>';
                              echo '<div class="picName">'.$value["name"].'</div>'; 
                              echo '<div class="picName">'.print_r($value).'</div>'; 
                             
                                echo " 
                                  <input type='button' value='invite friend'  style='background-color:blue;padding:5px;border:none;color:#fff;cursor:pointer'   onclick=\"invite_fb_friend( '$fbfid' )\"  />  
                                 "; 
                            echo '</li>';  
                               echo "<hr>"; 

                        } 
                    }


                  }
                  echo '</ul>'; 



            ?>























            <?php else: ?>
              <strong><em>You are not Connected.</em></strong>
            <?php endif ?>
 















 

        <script type="text/javascript"> 
            function invite_fb_friend ( fbid ) {
                 alert(fbid);
                 FB.ui({method: 'apprequests',
                    title: 'Friend Smash Challenge!',
                    to: fbid,
                    message: 'I just smashed   friends! Can you beat it?',
                }, fbCallback);
            } 


              function invite(to) {
                FB.ui({
                  method: 'send',
                  name: "please vote for me",
                  link: 'http://fashionsponge.com/fs',
                  picture:"http://fashionsponge.com/fs/images/FSlogo.jpeg",
                  to:to,
                  description:'A designers closeth...'
                });
              }
              function invites(){
                FB.ui({
                  method: 'apprequests',
                  name: "please vote for me",
                  link: 'http://fashionsponge.com/fs',
                  picture:"http://fashionsponge.com/fs/images/FSlogo.jpeg",
                  description:'A designers closeth...'
                });
              }



        </script> 

        <input type="button" value="invite friends" onclick="invite('123123')" /> 

          </body>
        </html> 



    <?php
    }
Beispiel #6
0
    public function social_login($type, $imgname = null, $link = null, $hoverImage = NULL, $id = NULL, $style = 'width:100%; height:auto;', $target = NULL)
    {
        switch ($type) {
            case 'facebook':
                ?>
	       				 	<!-- fb login  -->
								<div id="fb-root"></div>  
							    <script src="http://connect.facebook.net/en_US/all.js"></script>  
							    <script> 
								    // FB.init({ 
								    //   appId: '528594163842974', 
								    //   cookie: true,
								    //   status: true, 
								    //   xfbml: true 
								    // }); 
							    </script> 


							    <?php 
                require 'fs_folders/API/facebook-php-sdk-master/src/facebook.php';
                $facebook = new Facebook(array('appId' => '528594163842974', 'secret' => 'a411c8a3c4361556491b2c2ddf38bf21'));
                $user = $facebook->getUser();
                if ($user) {
                    try {
                        // $user_profile = $facebook->api('/me');
                        #echo "user logon!";
                    } catch (FacebookApiException $e) {
                        error_log($e);
                        $user = null;
                        #echo "user logout!";
                    }
                }
                if ($user) {
                    #echo " logout user";
                    $logoutUrl = $facebook->getLogoutUrl();
                    // $params = array(
                    //     'scope' =>' email,friends_about_me,user_about_me,user_birthday, user_education_history,
                    //     	user_games_activity, user_groups, user_hometown, user_interests, user_likes
                    //     	user_location, user_notes, user_online_presence, user_photo_video_tags, user_photos
                    //     	user_questions, user_relationship_details, user_relationships, user_religion_politics
                    //     	user_status, user_subscriptions, user_videos, user_website, user_work_history
                    //     	',
                    //     	'redirect_uri' => 'http://fashionsponge.com/social-fblogin-authenticate.php'
                    // );
                    $params = array('scope' => 'email', 'user_likes', 'user_about_me', 'name', 'first_name', 'last_name', 'age_range', 'link', 'gender', 'locale', 'timezone', 'user_education_history', 'user_hometown', 'user_website', 'user_work_history', 'user_birthday', 'redirect_uri' => 'http://dev.fashionsponge.com/social-fblogin-authenticate.php');
                    // $params = array(
                    //     'scope' =>' email,friends_about_me,user_about_me,user_birthday, user_education_history,
                    //     	user_games_activity, user_groups, user_hometown, user_interests, user_likes
                    //     	user_location, user_notes, user_online_presence, user_photo_video_tags, user_photos
                    //     	user_questions, user_relationship_details, user_relationships, user_religion_politics
                    //     	user_status, user_subscriptions, user_videos, user_website, user_work_history
                    //     	',
                    //     	'redirect_uri' => 'http://fashionsponge.com/social-fblogin-authenticate.php'
                    // );
                    $statusUrl = $facebook->getLoginStatusUrl();
                    $loginUrl = $facebook->getLoginUrl($params);
                } else {
                    #echo " set parametter to login ";
                    // $params = array(
                    //           'scope' =>' email,friends_about_me,user_about_me,user_birthday, user_education_history,
                    //           	user_games_activity, user_groups, user_hometown, user_interests, user_likes
                    //           	user_location, user_notes, user_online_presence, user_photo_video_tags, user_photos
                    //           	user_questions, user_relationship_details, user_relationships, user_religion_politics
                    //           	user_status, user_subscriptions, user_videos, user_website, user_work_history
                    //           	',
                    //           	'redirect_uri' => 'http://fashionsponge.com/social-fblogin-authenticate.php'
                    //       );
                    $params = array('scope' => 'email', 'user_likes', 'user_about_me', 'name', 'first_name', 'last_name', 'age_range', 'link', 'gender', 'locale', 'timezone', 'user_education_history', 'user_hometown', 'user_website', 'user_work_history', 'user_birthday', 'redirect_uri' => 'http://dev.fashionsponge.com/social-fblogin-authenticate.php');
                    $statusUrl = $facebook->getLoginStatusUrl();
                    $loginUrl = $facebook->getLoginUrl($params);
                }
                return $loginUrl;
                break;
            case 'print-image':
                echo "<a href='{$link}' target='{$target}' >\n\t       \t\t\t\t\t\t\t<img  \n\t       \t\t\t\t\t\t\t\tid='{$id}' \n\t       \t\t\t\t\t\t\t\tsrc='{$imgname}' \n\t       \t\t\t\t\t\t\t\tstyle='{$style}' \n\t       \t\t\t\t\t\t\t\tonmouseover=\"mousein_change_button ( '#{$id}' , '{$hoverImage}' )\"   \n\t       \t\t\t\t\t\t\t\tonmouseout=\"mousein_change_button ( '#{$id}' , '{$imgname}' )\"\n\t       \t\t\t\t\t\t\t/>\n\t       \t\t\t\t\t\t</a>";
                break;
            default:
                break;
        }
    }
Beispiel #7
0
 function fbooklog()
 {
     require 'facebook.php';
     $facebook = new Facebook(array('appId' => '613331932053999', 'secret' => '67ca1bf4c03ee0481ed13099676141de'));
     $user = $facebook->getUser();
     if ($user) {
         try {
             // Proceed knowing you have a logged in user who's authenticated.
             $user_profile = $facebook->api('/me');
         } catch (FacebookApiException $e) {
             error_log($e);
             $user = null;
         }
     }
     $deal_user = $facebook->api('/me');
     if ($user) {
         // $logoutUrl;
         /*	echo "<pre>";
         
         print_r($deal_user);
         
         echo "</pre>";die;*/
         $here = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
         $next = preg_replace('~#.*$~s', '', $here);
         $next = preg_replace('~\\?.*$~s', '', $next);
         $next = preg_replace('~/[^/]*$~s', '/logout.php', $next);
         $logoutUrl = $facebook->getLogoutUrl(array('next' => $next));
         $facebook_user = mysql_query("select * from " . USERS . " where user_name='" . $deal_user['username'] . "'");
         // echo $facebook_user;die;
         $location = $deal_user['location']['name'];
         //echo $facebook_user;die;
         $pic_url = "https://graph.facebook.com/" . $user . "/picture?type=large";
         //$n=mysql_num_rows($facebook_user);
         // echo $n;die;
         if (mysql_num_rows($facebook_user) == 0) {
             mysql_query("insert into " . USERS . " set name='" . $deal_user['name'] . "',user_name='" . $deal_user['username'] . "',email='" . $deal_user['username'] . "',profile_picture='" . $user . "',profile_picture_url='" . $pic_url . "',joindate=NOW()");
             $s = mysql_query("select * from " . USERS . " where user_id=" . mysql_insert_id());
             //echo $s;die;
             $resulet = mysql_fetch_assoc($s);
             //print_r($resulet);
             $SessionArray = array();
             foreach ($resulet as $k => $v) {
                 $SessionArray[$k] = $v;
             }
             $_SESSION['user'] = $SessionArray;
             header("location:./");
             //$_SESSION['user']['user_id']=
         } else {
             $u = mysql_query("update " . USERS . " set set name='" . $deal_user['name'] . "',user_name='" . $deal_user['username'] . "',profile_picture='" . $user . "',profile_picture_url='" . $pic_url . "',joindate=NOW() where email='" . $deal_user['username'] . "'");
             //echo $u;die;
             $resulet = mysql_fetch_assoc(mysql_query("select * from " . USERS . " where email='" . $deal_user['username'] . "'"));
             $SessionArray = array();
             foreach ($resulet as $k => $v) {
                 $SessionArray[$k] = $v;
             }
             $_SESSION['user'] = $SessionArray;
             header("location:./");
         }
     } else {
         $here = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
         $next = preg_replace('~#.*$~s', '', $here);
         $next = preg_replace('~\\?.*$~s', '', $next);
         $next = preg_replace('~/[^/]*$~s', '/index.php', $next);
         //global $statusUrl;
         //global $loginUrl;
         $statusUrl = $facebook->getLoginStatusUrl();
         $loginUrl = $facebook->getLoginUrl(array('next' => $next));
     }
     return $loginUrl;
 }