0

有没有人尝试在 php 中使用 curl 方法添加新场地?下面是我的代码:

<?php

$post_data['name']              = 'Test Residence';
$post_data['address']           = '123 Test Address';
$post_data['crossStreet']       = '';
$post_data['city']              = 'Test City'
$post_data['state']             = '';
$post_data['zip']               = '';
$post_data['phone']             = '';
$post_data['ll']                = '123.567,891.01112';
$post_data['primaryCategoryId'] = '4bf58dd8d48988d130941735';

foreach ( $post_data as $key => $value) {
    $post_items[] = $key . '=' . $value;
}

$post_string = implode ('&', $post_items);

$curl_connection = curl_init('https://api.foursquare.com/v2/venues/add');

curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT, 
  "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);

curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);

$result = curl_exec($curl_connection);

print_r(curl_getinfo($curl_connection));
echo curl_errno($curl_connection) . '-' . 
                curl_error($curl_connection);

curl_close($curl_connection);


?>

希望你能帮助我。我不确定 POST 是否成功,但没有返回任何错误。如果场地已更新,我尝试检查foursquare站点,但没有。谢谢。

4

1 回答 1

-1
    $post_data['name']              = 'xx';
    $post_data['address']           = '123 Test Address';
    $post_data['crossStreet']       = '';
    $post_data['city']              = 'Test City';
    $post_data['state']             = '';
    $post_data['zip']               = '';
    $post_data['phone']             = '';
    $post_data['ll']                = '-22.423741,-45.4596028';
    $post_data['primaryCategoryId'] = '';
    $post_data['client_id']         = '';
    $post_data['oauth_token']       = '';
    $post_data['v']                 = '';

试试看。Foursquare 需要 client_id (app key), oauth_token 和 v。

于 2015-03-02T14:04:37.863 回答