query Canvas URL using FQL - facebook

It seems like http://developers.facebook.com/docs/reference/fql/application/ provides all the information except for Canvas URL. Is it possible to query this information any other way?

Well, the solution I came up with, was simply calling the old admin.getAppProperties method.
$info = $facebook->api(array(
'method' => 'admin.getAppProperties',
'properties' => array('publish_url'),
));

Related

Facebook PHP SDK: Post attached photo to fanpage

in my working code to post a message with url-based image, i have this setup:
$post_data = array(
'message' => 'nice kitten pic',
'url' => 'http://www.eastcottvets.co.uk/uploads/Animals/gingerkitten.jpg'
);
$request = new FacebookRequest($app, $access_token, 'POST', '/' . $page_id . '/photos', $post_data);
i tryed this, which does not work:
$post_data = array(
'message' => 'nice kitten pic',
'source' => realpath('pics/kitten.jpg')
);
But now i like to post an image, not with an url reference, but with a reference to the path of the image on my localhost.
Facebook Docu says:
"There are two separate ways of publishing photos to Facebook:
1: Attach the photo as multipart/form-data. The name of the object doesn't matter, but historically people have used source as the parameter name for the photo. How this works depends on the SDK you happen to be using to do the post.
2: Use a photo that is already on the internet by publishing using the url parameter:"
So, way Nr.2 works, but how do i use way nr.1, with "attach the photo as multipart/form-data" ?? - the docu laks an example for php sdk and in general.
the docu laks an example for php sdk and in general.
No, it doesn’t – you’ve just missed it: https://developers.facebook.com/docs/php/howto/example_upload_photo
The part most relevant to your question is the use of the fileToUpload to prepare a local file for upload.
Solution, for people wo might search aswell:
$post_data = array(
'message' => 'nice kitten pic',
'source' => $fb->fileToUpload('/var/www/myPublicToTheWebFolder/kitten.jpg'),
);
of course the path will be different, depending on server setup. but it has to be the full path you have to output there.

Get nested ressources when using cakePhp restfull

I'm using cakePhp to create a Rest api (see http://book.cakephp.org/2.0/fr/development/rest.html) and I need to get nested resources. The documentation tells how to get let's say books implementing a URI /books.json. But does not tell how to get for example reviews for a given book. What I'm trying to make is somthing like this: /books/14/reviews.json that returns Review resources.
Can any one tell me hwo to make this?
See the Custom REST Routing section of the docs you've linked. In case the default routing doesn't work for you, you'll have to create your own custom routes that either replace or extend the default ones.
Your /books/14/reviews.json URL could for example be mapped to BooksController::reviews() likes this:
Router::connect(
'/books/:id/reviews',
array(
'[method]' => 'GET',
'controller' => 'books',
'action' => 'reviews'
),
array(
'id' => Router::ID . '|' . Router::UUID,
'pass' => array(
'id'
)
)
);
When placed before Router::mapResources() it should work fine together with the default routes.

Zend Routes translate URL's

1) I have a controller "calendar" and have action "showDate" which gets date via url. So, url is something like "calendar/show-date/date/2012-07-22"
2) I have a link to display all entries, "calendar/"
So, I want to create routes so my links look like "kalendar/2012-07-22" and "kalendar/".
Can anyone help me?
According to this post:
http://www.z-f.fr/forum/viewtopic.php?id=5138
The solution is to add '#locale' => $lang to the params.
$this->url(array('lang'=>'it','#locale'=>'it'))
It works very well for me.
I've been looking into translating the URL with Zend_Translate and I came across this sites' plugin that attempts to auto-translate URL segments (module/controller/action).
http://blog.helmich.cz/305-howto-simple-multilingual-routes-in-zend-framework/
The nice thing is that it's a modified custom router class that can function similar to Zend_Router so it's relatively familiar off the bat.
$pages = new MyApp_Controller_Router_Route(
':locale/:#controller/:#action/*',
array(
'controller' =>; 'index',
'action' => 'index',
'locale' => 'cs'
)
);
$router->addRoute('pages',$pages);
The thing you'll need is to have a language ID in your URL (called :locale in the above example) so your Zend_Translate can set the proper language.
www.example.com/en/calendar/2012-06-22/
www.example.com/fr/calendrier/2012-06-22/
www.example.com/de/kalender/2012-06-22/
www.example.com/it/calendario/2012-06-22/
I've only slightly played around with this concept but I recall that it had promise. You'll have to get more familiar with Zend_Translate: http://framework.zend.com/manual/en/zend.translate.html
I hope that helps!
Cheers!
You could re-route all calls of calendar to kalendar. There are two possibilites, either you do it with Zend (preferable) or you change your webserver configuration to rewrite calls to calendar with a HTTP 302 (ugly).
You should however consult the official Zend Documentation, which is pretty good
You have to setup custom routes, this is my way:
in folder application/configs/ create file named "routes.ini"
Put in file your route:
;index-homepage, parameter date isn't required
;"index" is key of your route
routes.index.route = "kalendar/:date"
routes.index.defaults.controller = calendar
routes.index.defaults.action = show
routes.index.defaults.date =
So in your bootstrap.php define that config file:
protected function _initRoute() {
$router = Zend_Controller_Front::getInstance()->getRouter();
$router->addDefaultRoutes();
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routes.ini');
$router->addConfig($config, 'routes');
}
And that's it, you can call URL
www.website.com/kalendar
and
www.website.com/kalendar/2012-1-1
See answers in this question for details:
Simple rewrites in Zend Framework

Using Zend Routes? to customized url

This is getting me confused.
How do I customize /state/state_name to be replaced by /state/state_name.php?
Initially state_name is a variable and I don't want each of the state to be an action in my StateController. Instead, I would like to take that variable and process it in a specific action loadAction() to deal with the contents.
This is because the url /state/state_name.php is already SEO optimized and I want it to stay in that form using Zend Framework.
Thanks for any help. Any suggestions would be gladly welcomed!
Maybe something like:
$route = new Zend_Controller_Router_Route_Regex(
'state/([^/]+)\.php',
array(
'controller' => 'state',
'action' => 'load',
),
array(
'state_name' => 1,
),
'state/%s.php'
);
But why is is so important to keep the .php suffix? If anything, it unnecessarily exposes the underlying server-side technology employed to construct the page. What if you later change the entire site to Ruby On Rails or to Django? Why tie yourself to PHP?
If you are really sweet for a suffix, then I'd imagine that .htm or .html is better. But even that leads you down a path with a potentially bad smell. What if you want to use this same controller to be the endpoint of an AJAX request that returns JSON or XML data?
Personally, I'd bail on the suffix.

An example of how to call admin.setRestrictionInfo from PHP SDK

This is what I got so far and the returned result is empty
$params = array(
"method"=>"admin.setRestrictionInfo",
"restriction_str"=>"{'age':'21+'}"
);
$this->fb->api($params)
According to this page
http://wiki.developers.facebook.com/index.php/Session_Secret_and_API_Methods
I need to pass the Application Secret along with this type of API call, but I can't figure it out how to do it with PHP SDK.
Any inputs, directions would be appreciate as well
Cheers
simple
$this->fb->setSession(); //set user session to null
$params = array(
"method"=>"admin.setRestrictionInfo",
"restriction_str"=>array("age"=>18+)
);
$this->fb->api($params);