I want to get patients details using MMJMenu api from my php application.
we can easily get MMJMenu items using it's api to our application but how to Patients details using api
Here using this code to get menuitems...
<?php
require 'API/Mmjmenu.php';
$client = new Mmjmenu('JHDGFDS46JSsdf654FSJHDSH');
$menuItems = $client->menuItems();
$menuItems = json_decode($menuItems, true);
foreach($menuItems['menu_items'] as $item)
{
echo $item['name'];
}
?>
If you read the API documentation for MMJMenu, you will see that you can only get Un-confirmed patients through the API. You cannot currently get a full list of patients through the MMJMenu API. See https://mmjmenu.com/docs/api/patients
Unless $menuItems['menu_items'] also is an array (which I doubt), you should be able to fix the issue by switching it to
foreach ($menuItems as $menuItem) {
echo $menuItem;
}
Related
I'm currently looking into selecting a single domain on the Adsense API to see if the domain is currently available in Adsense. Selecting all
domains goes well, but it seems a bit cumbersome to loop all properties. So I'm looking for a single select
Current code:
# Setup client
$client = new Google_Client();
$client->setAccessToken(GOOGLE_ACCESS_TOKEN);
# Setup api
$adsense = new \Google\Service\Adsense($client);
# Set Scope to adsense
$client->setScopes(['https://www.googleapis.com/auth/adsense']);
# list account sites
$ads = $adsense->accounts_sites->listAccountsSites("accounts/pub-xxxxxxxxxxxxxxxx");
#loop through the domains and check if in array
foreach ($ads as $a) {
$ad_sites[] = $a['domain'];
}
# Result:
$in_adsense = in_array($domain, $ad_sites)
What looks promising is the current doc by Google:
https://developers.google.com/adsense/management/reference/rest/v2/accounts.sites/get
And the corresponding get method: https://developers.google.com/adsense/management/reference/rest/v2/accounts.sites/get
I however can't seem to find the right syntax to select a single domain on the Google SDK. Any help would be appriciated.
Turns out I've overlooked a possibility to use a gRPC query. This turns out to be the following code, based on the example created by #Wahyu Kristianto.
$domain = "google.com";
$adsense = new \Google\Service\Adsense($client);
try {
$site = $adsense->accounts_sites->get("accounts/pub-xxxxxxxx/sites/{$domain}");
$in_adsense = true;
} catch (\Exception $e) {
$in_adsense = false;
}
So we're calling a gRPC query to the get method: accounts/pub-xxxxxxxx/sites/google.com
I am using the icontact php api. I want to get the last contact who entered the list so in the icontact api php I have this:
<php
public function getContacts() {
// Make the call and return the data
return $this->makeCall("/a/{$this->setAccountId()} /c/{$this->setClientFolderId()}/contacts?listId=49626&status=total&createDate=2015-02-16&createDateSearchType=gt", 'GET');
}
?>
than I use this to call it:
<?php
$oiContact = iContactApi::getInstance();
try {
var_dump($oiContact->getContacts());
} catch (Exception $oException) { // Catch any exceptions
var_dump($oiContact->getErrors());
}
$obj = $oiContact->getLastResponse();
$data = json_decode($obj,TRUE);
echo $data['contacts'][0]['email'];
echo $data['contacts'][0]['commitmentscore'];
echo $data['contacts'][0]['firstName'];
echo $data['contacts'][0]['phone'];
?>
It keeps giving me the same contact it is because the 0 in the echo but how can I make that a variable or an if condition just not sure how
paste bins with full code
http://pastebin.com/SBf73UNb //call
http://pastebin.com/CuGcCvU1 //api
This worked
/contacts?listId=49626&orderby=createDate:desc&limit=1", 'GET');
Got it from this page
http://www.icontact.com/developerportal/documentation/advanced-users/
I think you can use orderby option,
check this link
sample they used
Get all contacts on a list ordered by First Name GET https://app.sandbox.icontact.com/icp/a/<accountId>/c/<clientFolderId>/contacts?orderby=firstName
Instead of firstname you can use date, something like normal SQL query doing then fetch only first contact.
Also the return data will be always array so you have to run within a foreach for iterate the data.
Hope it helps.
I want to display the last 100 followers on Twitch using their API on my website. However, I know very little about JSON.
Currently I have this:
$string = file_get_contents("https://api.twitch.tv/kraken/channels/pewdiepie/follows.json?limit=100");
$json=json_decode($string,true);
But I can't get it in a while loop.
I tried this:
foreach ($json as $key => $value){
echo $value['name'];
}
Can someone help me? I just want the last 100 follower names displayed on the page.
Assuming that getting the data works, this should do it:
foreach ($json['follows'] as $follow){
echo $follow['user']['name'];
}
I'm trying to get all of the notes from a particular evernote notebook. I am able to display all of the data as an array, and I'm trying to use a foreach loop to get the title. I also want to be able to get the content, date, etc.
$filter = new NoteFilter();
$filter->notebookGuid = $notebookGuid;
$notelist = $client->getNoteStore()->findNotes($authToken, $filter, 0, 100);
foreach($notelist as $value) {
echo $value->title;
}
I know that I'm being really stupid, but I'm new to php and evernote. Any help is appreciated!
The return value of NoteStore.findNotes is NoteList which is not a collection. You have to get notes attribute from NoteList and then iterate it.
By the way, findNotes is now deprecated so please use findNotesMetadata.
You might want to check the following example from evernote:
https://github.com/evernote/evernote-sdk-php/blob/master/sample/client/EDAMTest.php
This script isn't working so good.
<?php
//include twitter class
require('classes/twitter.php');
$twitter = new Twitter('custToken', 'custSecret');
// set tokens
$twitter->setOAuthToken('blah blah');
$twitter->setOAuthTokenSecret('blah blah');
//$tweet = "This tweet was posted from a custom php script.";
//$twitter->statusesUpdate($tweet); // <-- this works!
$friends = $twitter->friendsList('tynamite');
foreach ($friends as $friend){
print_r($friend);
echo "<hr>";
}
?>
I want to display all my Twitter friends (everyone I follow) in a list.
The result I am getting is this.
Could anyone please help on this?
You should pass a cursor. You could use something like the code below (untested and just pseudo-code):
while($count == 20) {
$friends = $twitter->friendsList('tynamite', $cursor);
$count = count($friends);
$cursor++;
.. your code ..
}
twitter uses json to return its results. you need to parse the results returned and pull out the information you need. check this blog out for an example of how to use php to parse json