English 中文(简体)
显示“Face”用户的性别和其他
原标题:Displaying a Facebook user s sex and others

I m开始在Facebook提出申请,Im在获得一些用户信息方面遇到问题。

我获得的信息如下:

hometown_location
current_location
work

我的守则是:

<?php
    $app_id = "";
    $app_secret = "";
    $my_url = "";

    session_start();
    $code = $_REQUEST["code"];

    if(empty($code)) {
        $_SESSION[ state ] = md5(uniqid(rand(), TRUE)); //CSRF protection
        $dialog_url = "https://www.facebook.com/dialog/oauth?client_id="
          . $app_id . "&redirect_uri=" . urlencode($my_url) . "&scope=email,offline_access,publish_stream,user_birthday,user_education_history,user_location,user_hometown,user_relationships,user_relationship_details,user_work_history&state="
          . $_SESSION[ state ];

        echo("<script> top.location.href= " . $dialog_url . " </script>");
    }

    if($_REQUEST[ state ] == $_SESSION[ state ]) {
        $token_url = "https://graph.facebook.com/oauth/access_token?"
          . "client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url)
          . "&client_secret=" . $app_secret . "&code=" . $code;

        $response = file_get_contents($token_url);
        $params = null;
        parse_str($response, $params);

        $graph_url = "https://graph.facebook.com/me?access_token="
          . $params[ access_token ];

        $user = json_decode(file_get_contents($graph_url));
        echo("Hello " . $user->name. <br /> );
        echo("id " . $user->id. <br /> );
        echo("mail  " . $user->email. <br /> );
        echo("birthday  " . $user->birthday. <br /> );
        echo("sex  " . $user->sex. <br /> );
        echo("hometown_location  " . $user->hometown_location. <br /> );
        echo("relationship_status  " . $user->relationship_status. <br /> );
        echo("current_location  " . $user->current_location. <br /> );
        echo("education  " . $user->education. <br /> );
        echo("work  " . $user->work. <br /> );
    }
    else {
    }
 ?>

我与“性别”交织在一起,但我可以 figure出其他人。

最佳回答

您想要的特性是hometown>>> 所在地。 家乡要求用户发放<条码>用户_hometown,地点要求用户发放<条码>用户<>>>><>>>> 用户<> > 地址/代码>许可。

  ....
  "username": "alienwebguy", 
  "hometown": {
    "id": "112276852118956", 
    "name": "Maple Grove, Minnesota"
  }, 
  "location": {
    "id": "102825596420583", 
    "name": "Antioch, California"
  }, 
  ....

Per the Open Graph "User" API docs:

hometown    The user s hometown       user_hometown or friends_hometown   object containing name and id
location    The user s current city   user_location or friends_location   object containing name and id
问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签