title: Graph API direct message for page: how to retrieve link to attached file
body: <p>I need to store the link to a file attached to a direct message (for a page, retrieved with "<code>/conversations</code>"). How can I do that?</p>
  
  <p>I know how to get the link of an image. The JSON-object for an image ("<code>attachments</code>") contains the tag "<code>image_data</code>", which contains the tags "<code>url</code>" and "<code>preview_url</code>" for accessing the image.</p>
  
  <p>For attached <strong>files</strong> (in my case e.g. a PDF), FB only sends "<code>id</code>", "<code>mime_type</code>", "<code>name</code>" and "<code>size</code>", but no additional data. Example:</p>
  
  <pre><code>"id": "m_id.158623824339344"
   ....
  "attachments": {
      "data": [
       {
          "id": "7b84fd4c0f18fb4060ae0fe0dcfeb42e",
          "mime_type": "application/pdf",
          "name": "Attachment1.pdf",
          "size": 80798
        }
      ]
   }
  </code></pre>
  
  <p>But when I log into FB as a user and click the attachment in the browser, I get this link:</p>
  
  <pre><code>https://www.facebook.com/ajax/messaging/attachment.php?attach_id=&lt;attach_id&gt;&amp;mid=id.&lt;mid&gt;&amp;pageid=&lt;pageid&gt;&amp;ext=&lt;ext&gt;&amp;hash=AQCafpYeZj2pSjRk
  </code></pre>
  
  <p>By trial and error I found out that it is possible to access the file without the "<code>hash</code>" and "<code>ext</code>"-part. This means that in theory I am able to generate this link in my application ("<code>attach_id</code>" and "<code>mid</code>" are provided with the message and I know my pageid).</p>
  
  <p>But this seems to be very unreliable. This link might change anytime, breaking my application.</p>
  
  <p>I searched a lot but couldn't find any documentation about this. Does anybody know a better solution? Or can someone point me to some documentation regarding this issue?</p>
  
  <p>Thanks a lot!</p>
  
  <p>Barbara</p>