无法使用 jquery/ajax facebook graph api 上传照片,因为 formpost 数据错误

发布于 2024-11-01 19:51:04 字数 1575 浏览 0 评论 0原文

我有一个对 php 页面的 jquery-ajax 调用,该页面应该将用户照片上传到用户默认相册;但是当调用时发生错误,如下所示

创建模板数据失败 卷曲 异常

这里是上传用户照片的 jquery ajax 函数和 php 脚本的代码:

jquery-ajax 函数:

$.ajax({
  type: "GET",
  url: "./page1.php",//link to php page
  data: "link=" + lnk, //image path 
  success: function(msg){
                    alert('upd: '+msg);
                },
   error: function(msg){
                    alert('flt: '+msg);
                }

    });

php 脚本 (page1.php )

$lnk = $_REQUEST['link'];
$facebook->setFileUploadSupport(true);
$attachement = array(‘access_token’ => $session['access_token'],
‘source’ =>’@’ . realpath($lnk),
 ‘name’ => ‘my ------ friend’,
‘message’ => ‘m pic;get yours at http://apps.facebook.com//‘
);
$fb_photo = $facebook->api(‘me/photos’,'POST’,$attachement);

响应错误转储 ::::: :::::::::::::::::::::::::::::::::::::::::::::::::

> curlException occuring:
> [message:protected] => failed creating
> formpost data [string:private] =>
> [code:protected] => 26
> [line:protected] => 639
> [trace:private] => Array ( [0] =>
> Array (
> 
> [file] =>
> /home/*******/public_html/******/facebook.php [line] => 592 [function] =>
> makeRequest [class] => Facebook [type]
> => -> [args] => Array ( [0] => https://graph.facebook.com/me/photos
> [1] => Array (.....

请对此提供帮助; 会很棒的;

陷入这个问题;

i have a jquery-ajax call to php page that is supposed to upload user photos to users default album;but when call is made error occurs as

failed creating formpost data
curl
exception

here is the code of jquery ajax function and php script that uploads user photo:

jquery-ajax function:

$.ajax({
  type: "GET",
  url: "./page1.php",//link to php page
  data: "link=" + lnk, //image path 
  success: function(msg){
                    alert('upd: '+msg);
                },
   error: function(msg){
                    alert('flt: '+msg);
                }

    });

php script (page1.php )

$lnk = $_REQUEST['link'];
$facebook->setFileUploadSupport(true);
$attachement = array(‘access_token’ => $session['access_token'],
‘source’ =>’@’ . realpath($lnk),
 ‘name’ => ‘my ------ friend’,
‘message’ => ‘m pic;get yours at http://apps.facebook.com//‘
);
$fb_photo = $facebook->api(‘me/photos’,'POST’,$attachement);

dump of response error :::::::::::::::::::::::::::::::::::::::::::::::::::

> curlException occuring:
> [message:protected] => failed creating
> formpost data [string:private] =>
> [code:protected] => 26
> [line:protected] => 639
> [trace:private] => Array ( [0] =>
> Array (
> 
> [file] =>
> /home/*******/public_html/******/facebook.php [line] => 592 [function] =>
> makeRequest [class] => Facebook [type]
> => -> [args] => Array ( [0] => https://graph.facebook.com/me/photos
> [1] => Array (.....

please help regarding this;
it will be great;

stuck in this issue;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文