Good morning all,
I have been stuck on a piece of code for a while and decided to ask one of you and create an account on Stackoverflow. I hope you guys can help!
See image
Image 2, output on web
I need to read out the [exportResult] but I cannot get there. I can read it now as;
$administration = array('demo', '');
$soapclient = new SoapClient("https://www.cashweb.nl/?api/3.0/wsdl");
$theCall = $soapclient->export('', '','','','', $administration, '0');
var_dump($theCall); // all result
var_dump($theCall['exportResult'] // XML result
So, i tried to use:
$theCall['exportresult']['R0101'][0]['F0101'];
But that is not working. Can anyone help me out how I can read the F0101 tag?
Related
I want to put my fortnite stats on my website HTML/CSS. I find this.
But I don't know php very good, so I need your help. Must I delete this: 'your_api_key' and put : your_api_key without the ' ' ?
And lines like this:
$this->auth = new Fortnite_Auth($this);
$this->challenges = new Fortnite_Challenges($this);
$this->leaderboard = new Fortnite_Leaderboard($this);
$this->items = new Fortnite_Items($this);
$this->news = new Fortnite_News($this);
$this->patchnotes = new Fortnite_PatchNotes($this);
$this->pve = new Fortnite_PVE($this);
$this->status = new Fortnite_Status($this);
$this->weapons = new Fortnite_Weapons($this);
$this->user = new Fortnite_User($this)
Must I modify something?
(here are some informations:
-user_id: 501b9f2dfda34249a2749467513172bf
-username: NoMaD_DEEPonion
-platform: pc
-windows: season 5
)
For all this code, I used xammp server (I hope it's good)
Thank you for your help
You should always quote '' your key/strings. So it would look like:
$api->setKey('123qwerty456');
$api->user->id('NoMaD_DEEPonion');
Please read their documentation. You're supposed to get an API key from them to get started. And you don't have to edit Client.php. You're supposed to include the files instead. Try including Autoloader.php, since it requires the necessary files.
XAMPP is alright for development, but not suitable for production/public. Good luck!
What #sykez wrote.
I personally use https://fortniteapi.com/ to get the data. They also have a sweet POSTMAN page with different requests https://documenter.getpostman.com/view/4499368/RWEjoGqD
At last. I am not really sure that this will be a good project to start learning PHP from. I really suggest that you get to understand the basics of PHP first before you jump into API calls, processing arrays and more.
I'm actually building a PHP bot that reads the youtube live streaming chat, and store in a Database the message that contains a specific keyword wrote by the users during the livestream. All the logic is in place, what is missing is the feedback on chat when the bot is "triggered".
I looked everywhere but seams the PHP documentation is missing, if you look inside the PHP Classes there is the public function insert, but there is no example at all on how to use it?
Someone know how to use it?
Should be something "simple" like: $result = $youtube->liveChatMessages->Insert($args); but I can't figure out on what args looks like.
HERE the only reference about the Insert method
Thanks to all for any suggestion on how to use it!
17/06/2018 edit Working Example
$liveChatMessage = new Google_Service_YouTube_LiveChatMessage();
$liveChatSnippet = new Google_Service_YouTube_LiveChatMessageSnippet();
$liveChatSnippet->setLiveChatId($liveChatID);
$liveChatSnippet->setType("textMessageEvent");
$messageDetails = new Google_Service_YouTube_LiveChatTextMessageDetails();
$messageDetails->setMessageText("Message to type in chat");
$liveChatSnippet->setTextMessageDetails($messageDetails);
$liveChatMessage->setSnippet($liveChatSnippet);
$videoCommentInsertResponse = $youtube->liveChatMessages->insert('snippet', $liveChatMessage);
I’m trying to get my online status using XMPPHP and I can’t seem to get anything that has my status from the $conn. Here is a snippet of my code:
require_once('XMPPHP/XMPP.php');
$conn = new XMPPHP_XMPP('talk.google.com', 5222, 'xxxx#gmail.com', 'xxxxx', 'xmpphp', 'gmail.com', $printlog = false, $loglevel = XMPPHP_Log::LEVEL_INFO);
$conn->connect();
$conn->processUntil('session_start');
$conn->presence($status='Controller available.');
var_dump($conn); // this gives me a long output but nothing about status. ex: http://pastebin.com/yfs1V5Jb
I also tried getRoster() to see a list of my friend’s info (although I’m only interested in mine) but no luck.
Any suggestions how I can get this to work? Thanks.
I've been grappling with this issue for the last 2 days, and finally figured out a hack to get things to work. I'm documenting it here, because this was the stack overflow question that appeared most often for me while searching for answers.
The $conn->presence() method not only sends your presence info to the server; it also collects presence info for every contact from the server. The fundamental problem is that when you send the $conn->presence() command, you have to give the script time to receive and process this information from the server. The example scripts all use $conn->processUntil('presence') to do this, but for some reason for me that didn't pause things long enough to get all the roster information.
To get around this, I finally just used $conn->processTime(2), forcing things to wait 2 seconds before proceeding. This is good enough for my purposes, but is clearly a hack. So using your code as an example:
require_once('XMPPHP/XMPP.php');
$conn = new XMPPHP_XMPP('talk.google.com', 5222, 'xxxx#gmail.com', 'xxxxx', 'xmpphp', 'gmail.com', $printlog = true, $loglevel = XMPPHP_Log::LEVEL_VERBOSE);
$conn->connect();
$conn->processUntil('session_start');
$conn->presence($status='Controller available.');
$conn->processTime(2);
// now see the results
$roster = $conn->roster->getRoster();
print_r($roster); // you should now see roster array with presence info for each contact
To answer your question more specifically, you could use the following in place of the code under "now see the results":
$my_jid = 'user#domain.tld'; // put your jid here
$status = $conn->roster->getPresence($my_jid);
echo $status['show'];
That will display the online status for the jid you provide.
Note that in this example I also changed the constructor to display the most verbose log possible. This was key to helping me work through this.
A better solution would obviously be to add a $conn->processUntil('roster') command to the framework, or something like that. But since the framework hasn't been updated in 5 years, that's unlikely to happen.
Hopefully this will save someone the hours I lost trying to solve it. Cheers.
You should be able to request your own presence by passing your own jid (username#gmail.com) to getPresence();
For example:
$status = $conn->roster->getPresence($jid);
var_dump($status); // Make sure you are retrieving a populated presence array
echo $status['show']; // available,unavailable,dnd
echo $status['status']; //status message
Quite a while back I ran into an issue with this library not populating roster records. If you run into this issue, you should apply the patch detailed here: https://code.google.com/p/xmpphp/issues/detail?id=44&q=empty
In Short, I am pulling the feed from my blogger using the Zend API in PHP. I need to get the URL that will link to that post in blogger. What is the order of functions I need to call to get that URL.
Right now I am pulling the data using:
$query = new Zend_Gdata_Query('http://www.blogger.com/feeds/MYID/posts/default');
$query->setParam('max-results', "1");
$feed = $gdClient->getFeed($query);
$newestPost = $feed->entry[0];
I can not for the life of me figure out where I have to go from here to get the URL. I can successfully get the Post title using: $newestPost->getTitle() and I can get the body by using $newestPost->getContent()->getText(). I have tried a lot of function calls, even ones in the documentation and most of them error out. I have printed out the entire object to look through it and I can find the data I want (so I know it is there) but the object is too complex to be able to just look at and see what I have to do to get to that data.
If anyone can help me or at least point me to a good explanation of how that Object is organized and how to get to each sub object within it, that would be greatly appreciated.
EDIT: Never mind I figured it out.
You are almost there, really all you need to do is once you have your feed entry is access the link element inside. I like pretty URLs so I went with the alternate rather than the self entry in the atom feed.
$link = $entry->link[4]->href;
where $entry is the entry that you are setting from the feed.
The solution is:
$query = new Zend_Gdata_Query('http://www.blogger.com/feeds/MyID/posts/default');
$query->setParam('max-results', "1");
$feed = $gdClient->getFeed($query);
$newestPost = $feed->entry[0];
$body = $newestPost->getContent()->getText();
$body now contains the post contents of the latest post (or entry[0]) from the feed. This is just the contents of the body of the post, not the title or any other data or formatting.
Hey guys,
feel stupid for asking this question but I'm stuck and new with getting values from JSON.
In the JSON example of the statuses/mentions of the Twitter API: http://dev.twitter.com/doc/get/statuses/mentions
I'm trying to get the 'screen_name' value from with the 'user' directory/array piece (don't know the term). Heres what I'm using to pull values currently:
$lastmentions = $oauth->get('http://api.twitter.com/1/statuses/mentions.json');
$lastmentionsuser = $lastmentions[0]->user;
Thanks guys, Dex
This should work:
$screen_name = $lastmentionsuser->screen_name;
Woop Woop figured it!
It was:
$lastmmentionsuser = $lastmmentions[$i]->user->screen_name;