2012-09-19 4 views
0

그래프 API로 사진을 게시하려고합니다. 게시 할 수없는 방법입니다. 이 오류를 얻을페이 스북 (Facebook) API에서 사진 찍기 : 일부 배열 '키'또는 Json 인 코드가 원인이라고 생각합니다.

어레이 ([에러 => 배열 ([메일] => (# 100) 잘못된 파라미터 [형태] => OAuthException [코드] => 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)); 

OUTPUT

 [{"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)) 
+0

태그 위치가 하드 코드 된 것처럼 보입니다. 정책이 어떻게 준수되고 있습니까? - 사진에 실제로 있지 않은 사용자의 태그를 지정하는 것 같습니다. – Igy

+0

@Igy - 아니, 실제로 데이터베이스에서 오는 것입니다. 그리고 사용자가 있습니다. 해당 부분이 잘 작동하므로 그림을 편집 한 부분을 제거했습니다. 이것은 오류가있는 부분입니다 – Yahoo

답변

1

문제는 x는, y는 어디에 좌표 내 코드입니다 태그를 추가하려고합니다. 100

- 비율

즉 (X 용)/(Y의 경우) 상단 왼쪽에서

X를 영상의 에지 오프셋 및 y는 0 사이 정상적으로

X 및 Y는되어야

Facebook Documentation

당신은 rand() 기능

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

이 될 수 있습니다 사용할 수 있습니다 너를 도울거야. :)

+0

고마워요, 나는 그것들이 X Y co-Ordinate ...라고 생각했습니다! :) – Yahoo