Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to share Amazon authenticated URL when posting to the wall using Facebook Graph API?

I am trying to create a Facebook wall post using Facebook Graph API. The payload is:

{ :message => 'I just uploaded image',
  :picture => 'http://s3.amazonaws.com/picyou-andrey-development/images/GejoFV/GejoFV.png?AWSAccessKeyId=AKIAI6ANFCV7RKOBGGBA&Signature=U0Bd2bMQ3Pai%2BAblVOimSOVcbzk%3D&Expires=1308771841',
  :link    => 'http://google.com',
  :name    => 'Test Post' }

The post is created properly but the problem in picture which does not displays at all.

When I was using public Amazon S3 URLs like http://s3.amazonaws.com/picyou-andrey-development/images/GejoFV/GejoFV.png picture was displayed correctly.

Any chance to use dynamic URLs as a 'picture' param with Facebook?

Thanks in advance.

Update:

Found a guy on the Facebook developer forum with exactly the same problem:

http://forum.developers.facebook.net/viewtopic.php?pid=302856

like image 227
Andrey Chernih Avatar asked Nov 13 '22 21:11

Andrey Chernih


1 Answers

Could it be that the signature part of the url has some chararcters in it that have special meaning in urls - %2B (+) and %3D (=)?

I have run into a problem with these urls in some video players and solved it by making sure that the url doesn't have any of those characters. You can do this by generating the url in a loop and adding a second onto the expiry time everytime to ensure the signature changes. Repeat until the signature is 'valid'

psuedocode:

loop
    expiry = expiry + 1 second
    create url with expiry
until url is valid

In my experience it only takes an iteration or two for the url to be valid.

like image 190
Geoff Appleford Avatar answered Jan 16 '23 10:01

Geoff Appleford