Page MenuHomePhabricator

How to find my subscribed phame blogs in php code?
OpenPublic

Asked by huangsj on Nov 25 2016, 6:24 AM.

Details

In conduit applications, I can search for my subscribed phame blogs by adding constraints as follows. The following curl does only list phame blogs that user huangsj subscribes to.

curl http://mso.yidian-inc.com/api/phame.blog.search \
    -d api.token=api-token \
    -d constraints[subscribers][0]=huangsj

But when I write php code, I don't know how to specify constraints.

I modify PhameBlogSearchEngine.php as follows. However, the "subscribed" query shows all blogs instead of those subscribed by huangsj

public function buildSavedQueryFromBuiltin($query_key) {
   $query = $this->newSavedQuery();
   $query->setQueryKey($query_key);

   $viewer_username = $this->requireViewer()->getUsername();

   switch ($query_key) {
     case 'all':
       return $query;
     case 'subscribed':
       $query->setParameter('constraints', array('subscribers' => array($viewer_username)));
       return $query;

What is the equivalent php code to that of curl?