Facebook Custom Story API PHP

+1 Nikola Novakovic · December 20, 2014
I am building an web app that is highly dependent on users ability to share a custom story on facebook. I managed somehow to get that custom story working but I can not manage to actually dynamically ( or statically not important ) set the url on which the users gets to when he clicks on the title of the action. I am talking about
og:title

 meta tag. I want that tag to be lead to a certain url , for example  
example.com/books.php?book_id=2

 ( I know its not a pretty url , it will be later but this is just for testing purposes ) How can I achieve that ?
I used custom story action and object and registered the app. I understand it to a certain extend how everything functions there but I can not seem to grasp how to actually make that title lead to a url taht I want it to lead to. I am not talking about the title of the app, since I know that leads to the index page of your web app which is logical, I am talking about the title to of the custom story , how can I control where that leads. Above is sample php code user
$graphObject = (new FacebookRequest( $session,
'POST','/me/sample_name:start',  array(
   'aim' => "http://samples.ogp.me/44445555554",
   'message'=>"Something in the message",
   'title'=>'Something in the title', // <--- I want this title to lead to the url param below
   'url'=>'example.com/books.php?book_id=2',

'image[0]'=>"example.com/link_to_image"
)))->execute()->getGraphObject()->asArray();
<meta property="og:site_name" content="Example"/>
<meta property="og:title" content="Something in the title"/>
<meta property="og:url"
content="example.com/books.php?book_id=2"/>
<meta property="og:description" content="Some description"/>
So at the end the output on facebook should be something like " John Doe reads a book on Bookstore " and below that is the picture of the book the title of the book ( title of the book that leads to that link mentioned above ) and a description below.
I have set up things like "reads" , "book" and "Bookstore" on their developer.facebook.com site, and followed those insturctions in the documentation but I can not get this to work. Hopefully I was clear enough , if I was not please ask what is not clear and I would gladly answer.
Thanks in advance! :)
">
And here are the meta tags:
<meta property="og:type" content="sample_name:start"/>
<meta property="og:site_name" content="Example"/>
<meta property="og:title" content="Something in the title"/>
<meta property="og:url"
content="example.com/books.php?book_id=2"/>
<meta property="og:description" content="Some description"/>

So at the end the output on facebook should be something like " John Doe reads a book on Bookstore " and below that is the picture of the book the title of the book ( title of the book that leads to that link mentioned above ) and a description below.
I have set up things like "reads" , "book" and "Bookstore" on their developer.facebook.com site, and followed those insturctions in the documentation but I can not get this to work. Hopefully I was clear enough , if I was not please ask what is not clear and I would gladly answer.
Thanks in advance! :)

Post a Reply

Replies

Oldest  Newest  Rating
0 Nikola Novakovic · December 20, 2014
Not sure why the hell is everything duplicated but hopefully you get the point. If not let me know I will write another post hopefully not duplicated :) 
  • 1

PHP

107,167 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators