使用Graph API检查

时间:2012-12-16 10:29:56

标签: php facebook facebook-graph-api

我尝试签入,PHP代码中的部分:

$attachment =  array('access_token' => '$access',                        
                     'place'        => '117464364938130',
                     'message'      => 'I am place to check in',
                     'coordinates'  => array(
                              'latitude'  => '40',
                              'longitude' => '-73',)
                    );

但我收到错误:

{"error":{"message":"(#160) Invalid coordinates. Coordinates must contain at least latitude, and longitude.","type":"OAuthException","code":160}}

为什么?

2 个答案:

答案 0 :(得分:0)

您应该将坐标编码为JSON

$attachment =  array('access_token'  => '$access',                        
                     'place'          => '117464364938130',
                     'message' => 'I am place to check in',
                     'coordinates' => json_encode(array(
                                        'latitude'  => '40',
                                        'longitude' => '-73')))

答案 1 :(得分:0)

尝试以下方法:

$attachment =  array('access_token' => '$access',                        
                     'place' => '117464364938130',
                     'message' => 'I am place to check in',
                     'coordinates' => '{"latitude": 40, "longitude": -73}');

顺便说一句,你不应再使用Checkin对象,否则你可能会遇到更多问题。相反,请使用Post。此外,您无需指定坐标,无论如何都可以解决您的问题!另请阅读我的帖子here