0

我正在尝试通过图形 API 在 facebook 上发布图片,但我无法发布。我收到这个错误

Array ( [error] => Array ( [message] => (#100) Invalid parameter [type] => OAuthException [code] => 100 ) )

这是我的代码

$sqls= mysql_query($sql);
    while($sqlr = mysql_fetch_array( $sqls, MYSQL_NUM ))
 {
     $users[]= $sqlr['regidfriendsid'];
 }

 for ($t=0 ; $t<3;$t++)
 {

$tag[$t] = array( 'tag_uid' => ($users[$t]), 'x' => (20+$x), 'y' => (85+$y) );

$x=$x+200;
$z++;
        if ($z%4==0)
        {
        $y=$y+178;
        $x=0;

        }
 }

$tag = array($tag[1], $tag[2], $tag[3]);    

$tags = json_encode($tag);
print_r($tags);
// end loop for tags


//upload photo
$file= 'styleimage/save_as_this_name.jpg';
$args = array(
   'message' => 'My Stylish friends',
    'tags' => $tags, 
);
print_r($args);
$args[basename($file)] = '@' . realpath($file);
$ch = curl_init();
$url = 'https://graph.facebook.com/me/photos?access_token='.$_SESSION['access_token'];
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
$data = curl_exec($ch);
//returns the photo id
print_r(json_decode($data,true));

输出

        [{"tag_uid":"100003656759153","x":220,"y":85},{"tag_uid":"100004078326378","x":420,"y":85},{"tag_uid":"100000034798548","x":620,"y":85}]@@@@@Array ( [message] => My Stylish friends [tags] => [{"tag_uid":"100003656759153","x":220,"y":85},{"tag_uid":"100004078326378","x":420,"y":85},{"tag_uid":"100000034798548","x":620,"y":85}] ) 

--Before posting the actual content of tags . Now trying to post ---

    Array ( [error] => Array ( [message] => (#100) Invalid parameter [type] => OAuthException [code] => 100 ) )
4

1 回答 1

1

问题是您要添加标签的 x,y 坐标。

x 和 y 应该是图片左侧(对于 x )/顶部(对于 y )边缘的百分比偏移量,即

x 和 y 应该在 0 - 100 之间。

Facebook 文档

你可以使用rand()函数

x = rand ( 0, 100 );
y = rand ( 0, 100 );

可能这会帮助你。:)

于 2012-09-20T07:44:00.530 回答