duanqiao2225 2016-09-12 13:25
浏览 44

Foursquare照片/添加Venue php

I'm trying to upload a photo to a venue on foursquare.

This my code :

$image = "/assets/uploads/image/test.jpg";

$fields = json_encode(array("photo" => "@".$image));

$url = "https://api.foursquare.com/v2/photos/add?oauth_token=<my-oauth-token>&v=20160609&venueId=<my-venue-id>";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20000);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
//curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents($s));
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: image/jpeg"));

$response = curl_exec($ch);

echo $response; exit;

and response

{"meta":{"code":400,"errorType":"other","errorDetail":"Missing file upload","requestId":"57d6abf3498e0eb7f4639fa1"},"notifications":[{"type":"notificationTray","item":{"unreadCount":12}}],"response":{}}

Obviously I added the customs token and venue id. I tried to add a tip via curl, no problem. I use codeigniter and php5.4

More info on foursquare API https://developer.foursquare.com/docs/photos/add

Thanks for the help!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 解决一个加好友限制问题 或者有好的方案
    • ¥15 关于#java#的问题,请各位专家解答!
    • ¥15 急matlab编程仿真二阶震荡系统
    • ¥20 TEC-9的数据通路实验
    • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
    • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
    • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
    • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
    • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
    • ¥30 求解达问题(有红包)