Integrate into User's Profile, Pages or Groups App
Integrate into User's Profile, Pages or Groups App
Support user's profile submenu
Implement hooks "mobile.service_userapi_getprofilemenu_end.php" using the following example code to add a menu to the user's profile page
Code Block | ||||
---|---|---|---|---|
| ||||
<?php |
...
/** |
...
* Add post navigation to user profile menu |
...
*/ |
...
if (isset($query) && isset($local) && isset($result) && Phpfox::isModule('post') && isset($user)) { |
...
$result['post'] = |
...
[ 'label' => $local->translate("posts"), |
...
'path' => "post/list-item", |
...
'params' => |
...
[ 'headerTitle' => $local->translate('full_name_s_item', ['full_name' => $user['full_name'], 'item' => $local->translate("posts")]), |
...
'query' => $query, |
...
], |
...
]; |
...
} |
...
Verify User Detail Api to make sure that your code works
...
with API Call: /user/{user_id}?access_token={{token}}
...
Support pages detail app submenu
...
If your app
...
is integrated to Pages app,
...
in this case, we need to add a menu to view all items
...
belonging to the page and a button to
...
create a new post in page
...
Let's add new Hook "/mobile.service_pageapi_getprofilemenu_end.php" in your phpFox app using the following code
Code Block | ||||
---|---|---|---|---|
| ||||
<?php |
...
if (isset($query) && isset($local) && isset($result) && Phpfox::isModule('post') && isset($page)) { |
...
$result['post'] = |
...
[ 'label' => $local->translate("posts"), |
...
'path' => "post/list-item", |
...
'params' => |
...
[ 'headerTitle' => $local->translate('full_name_s_item', ['full_name' => $page['title'], 'item' => $local->translate("posts")]), |
...
'query' => $query, |
...
// Add create |
...
button 'headerRightButtons' => |
...
[ [ 'icon' => 'plus', |
...
'action' => Screen::ACTION_ADD, |
...
'params' => |
...
[ 'resource_name'=> 'post', |
...
'module_name'=> 'post', |
...
'query' => |
...
[ 'item_id' => $page['page_id'], |
...
'module_id' => 'pages' |
...
]
]
]
]
],
];
} |
Now, verify Get Detail Pages API to make sure it
...
responds details of the integrated app
API Call: /pages/1?access_token={{token}}
...
Support groups detail app submenu
...
If your app
...
is integrated with Groups app
...
, you need to add a menu to view all items
...
belonging to the group and a button to
...
create a new post in the group
Add new Hook "/mobile.service_groupapi_getprofilemenu_end.php" in your app using the following code
Code Block | ||||
---|---|---|---|---|
| ||||
<?php |
...
if (isset($query) && isset($local) && isset($result) && Phpfox::isModule('post') && isset($page)) { |
...
$result['post'] = |
...
[ 'label' => $local->translate("posts"), |
...
'path' => "post/list-item", |
...
'params' => |
...
[ 'headerTitle' => $local->translate('full_name_s_item', ['full_name' => $page['title'], 'item' => $local->translate("posts")]), |
...
'query' => $query, |
...
// Add create |
...
button 'headerRightButtons' => |
...
[ [ 'icon' => 'plus', |
...
'action' => Screen::ACTION_ADD, |
...
'params' => |
...
[ 'resource_name'=> 'post', |
...
'module_name'=> 'post', |
...
'query' => |
...
[ 'item_id' => $page['page_id'], |
...
'module_id' => 'pages' |
...
]
]
]
]
],
];
} |
Now, you can verify Get Detail Groups API to make sure it has response your integration
API Call: /groups/{group_id}?access_token={{token}}
The response would be
...
same as one of Pages
...
integration