title: Tagging photos on Facebook with Graph API / PHP SDK
body: <p>The question is pretty much in the title, but to be more specific, I'm working on a facebook contest for a client in which people have to upload photos to take part in it after accepting rules and subscribing, etc.</p>
  
  <p>After going down a long road full of deceptions
  (here's what I tried that didn't work in the end:</p>
  
  <ul>
  <li>uploading to the user's album then tagging the page: nope, can't tag a page</li>
  <li>uploading to a public album in the page, like "fan photos", or wall photos? can't find anything AT ALL about a way to do this, though it would've been my preferred way.)</li>
  </ul>
  
  <p>So, I ended up having an idea: I would do this in two steps. First, the user subsribes and uploads a photo to my PHP server. Then, another, different application with permissions on the account that has the page, would take control of it, upload all the photos at 5 minutes intervals (meaning, you subsribe, 5 minutes later, your photo's uploaded.)</p>
  
  <p>So far, so good; I don't like the logic behind this, but it's the only way I found! So, I did the base, I'm able to post a photo with a caption as the page in a dedicated app album.
  BUT! I can't tag anyone in those photos. Maybe you can't tag as a page, maybe you can't tag in page albums, maybe I don't have the permissions required (I have stream_publish, user_photos, friends_photos, offline_access, and I could add anything if I need to since it's a private-use app anyway). Oh and, the user I'm trying to tag is the admin for both the app and the page (and he likes the page). I don't know, but it's driving me crazy. I hate the official documentation, there's no example code, you have to figure out most of the things, go through trial and error or search on the web for people who did so and shared how to do things. Not nice when you have little time to complete a project for a client without busting the budget.</p>
  
  <p>Anyway, here's my error I keep getting whenever I try to tag someone to a photo from any album:</p>
  
  <pre><code>OAuthException: (#322) Invalid photo tag subject
  </code></pre>
  
  <p>And here's the code I'm using to upload a photo from the server to facebook.</p>
  
  <pre><code>if ($user) {
    try {
      $page_info = $facebook-&gt;api("/$page_id?fields=access_token");
  if( !empty($page_info['access_token']) ) {
     // First method, at the same time as upload. Upload works but no tags
     $args = array(
     'access_token'  =&gt; $page_info['access_token'],
     'source' =&gt; '@' . realpath($FILE_PATH),
     'message' =&gt; "test"
     'tags' =&gt; array(
       array(
        'tag_uid'=&gt; "MY_USER_ID",
        'x'      =&gt; 0,
        'y'      =&gt; 0
       ))
     );
     $post = $facebook-&gt;api("/$page_id/photos","post",$args);
     $postID = $post['id'];
  
     // Second method I'm trying. No tags.
     $tag = $facebook-&gt;api("/$postID/tags/MY_USER_ID","post");
     print_r($tag);
  
  }
    } catch (FacebookApiException $e) {
  error_log($e);
  $user = null;
    }
  }
  </code></pre>
  
  <p>Any help would be appreciated. Thanks in advance!</p>
  
  <p>EDIT :: Now I got it partly working using the second part in the code, but only if I remove the "access_token" parameter from the photo posting first. Basically, it only works if I upload it to a personal album. But that's as far as it gets from what I want. When I upload it to the album from the page, it says I asked for tag requests, but on my personal account which I tagged, I don't receive anything. Baaaah.</p>
  
  <p>RE-EDIT :: After much tries, it seems I can't tag someone as a page or in a page album. I'll try to find an alternative, I guess.</p>