I have a hard time making a phpscript of the WSDL code found on http://network.thinkaction.com/api/soap_affiliate.php?wsdl
It is a directtrack code and I don't recieve any when I use the script below. I have just made an incentive based website so I have to see who with what e-mail has completed a survey and how much he completed from day 1 to day 12.
<?php
$url = "http://network.thinkaction.com/api/soap_affiliate.php?wsdl";
$client = new SoapClient("$url");
$result = $client->optionalInfo(
array('client' => '000000',
'add_code' => 'CD00000',
'password' => '000000000000000')
);
echo ('$results');
?>
Hope someone can help me,
Thanks
Your client code and password aren't here, so I can't run the code to test it out, a few observations.
http://soapclient.com/soaptest.html is a great way to get a look at how a SOAP API should work, when I run in to trouble I often execute calls there first.
Your code will currently print $results literally. I would suggest var_dump($results); during development and testing.
Related
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?
Having read documentations and tutorials for hours, I ended up in more confusion after all. So, here I'm asking for your help/tips and I'd really appreciate any effort helps me take a step further. Sorry for any mistakes I might possibly make, I'm quite newbie on this topic, so to say.
I'm building a web application, actually a single web page, that will start running as soon as it receives a GET/POST request from an external source. So, the page will be updated asynchronously if any request is received, for which I thought of using AngularJS and AngularFire on the front-end later on. I know there are many other ways and probably much simpler too, but I'm quite curious about how to integrate my CakePHP application with Firebase platform. So, let's stick with CakePHP + Firebase solutions for now.
So far, using the SDK Firebase PHP Client made much sense, however, I'm still confused about the files that needs to be manipulated. Since there are simply not many -I've found none so far- examples that use CakePHP3 Framework with Firebase, I'm stuck here and I'd really appreciate any help here. Firstly, this code is given in the link and I wonder how it works and what those vars and constants stand for.
const DEFAULT_URL = 'https://kidsplace.firebaseio.com/';
const DEFAULT_TOKEN = 'MqL0c8tKCtheLSYcygYNtGhU8Z2hULOFs9OKPdEp';
const DEFAULT_PATH = '/firebase/example';
$firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);
// --- storing an array ---
$test = array(
"foo" => "bar",
"i_love" => "lamp",
"id" => 42
);
$dateTime = new DateTime();
$firebase->set(DEFAULT_PATH . '/' . $dateTime->format('c'), $test);
// --- storing a string ---
$firebase->set(DEFAULT_PATH . '/name/contact001', "John Doe");
// --- reading the stored string ---
$name = $firebase->get(DEFAULT_PATH . '/name/contact001');
And here is the main question, assuming that I have a test function on one of the end points of my application, let say www.example.com/visits/test, how do I make sure that my application is integrated to Firebase platform and any request sent to that end point is being listened continuously?
Here is how I solved it, just so you know. It's needed to add a test end point to the controller file that you're using. You can find your token using Project Settings in your project file. A quick example is below.
public function test()
{
$DEFAULT_URL = 'YOUR_URL';
$DEFAULT_TOKEN = 'YOUR_TOKEN';
$DEFAULT_PATH = '/';
$firebase = new \Firebase\FirebaseLib($DEFAULT_URL, $DEFAULT_TOKEN);
$lines = [
"I had a problem once",
"I used Java to solve it",
"Now, I have ProblemFactory",
];
foreach ($lines as $line) {
$foo = $firebase->push($DEFAULT_PATH."code/",$line);
echo "child_added";
sleep(0.1);
echo "<br> ";
}
Then, in order to capture the lines added on the front-end, you may use a code similar to the code below. You can easily reach the version that fits your code from your firebase console by clicking Add "firebase to your web app" button or sth like this.
<script src="https://www.gstatic.com/firebasejs/live/3.0/firebase.js"> </script>
<script>
// Initialize Firebase
var config = {
apiKey: "YOUR_API_KEY",
authDomain: "YOUR-DOMAIN",
databaseURL: "YOUR_URL",
storageBucket: "YOUR_BUCKET",
};
firebase.initializeApp(config);
var codeRef = firebase.database().ref('code/');
codeRef.on('child_added', function(data) {
console.log(data.val());
});
</script>
I'm not done with the app yet, however, this insight may help you deal with similar issues.
Information
I've started using the Asana API to make our own task overview in our CMS. I found an API on github which helps me a great deal with this.
As I've mentioned in an earlier question, I wanted to get all tasks for a certain user. I've managed to do this using the code below.
public function user($id)
{
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) &&
($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')) {
$this->layout = 'ajax';
}
$asana = new Asana(array(
'apiKey' => 'xxxxxxxxxxxxxxxxxxxx'
));
$results = json_decode($asana->getTasksByFilter(array(
'assignee' => $id,
'workspace' => 'xxxxxxxxxx'
)));
if ($asana->responseCode != '200' || is_null($results)) {
throw new \Exception('Error while trying to connect to Asana, response code: ' . $asana->responseCode, 1);
}
$tasks = array();
foreach ($results->data as $task) {
$result = json_decode($asana->getTaskTags($task->id));
$task->tags = $result->data;
$tasks[] = $task;
}
$user = json_decode($asana->getUserInfo($id));
if ($asana->responseCode != '200' || is_null($user)) {
throw new \Exception('Error while trying to connect to Asana, response code: ' . $asana->responseCode, 1);
}
$this->render("tasks", array(
'tasks' => $tasks,
'title' => 'Tasks for '.$user->data->name
));
}
The problem
The above works fine, except for one thing. It is slower than a booting Windows Vista machine (very slow :) ). If I include the tags, it can take up to 60 seconds before I get all results. If I do not include the tags it takes about 5 seconds which is still way too long. Now, I hope I am not the first one ever to have used the Asana API and that some of you might have experienced the same problem in the past.
The API itself could definitely be faster, and we have some long-term plans around how to improve responsiveness, but in the near-to-mid-term the API is probably going to remain the same basic speed.
The trick to not spending a lot of time accessing the API is generally to reduce the number of requests you make and only request the data you need. Sometimes, API clients don't make this easy, and I'm not familiar with the PHP client specifically, but I can give an example of how this would work in general with just the plain HTTP queries.
So right now you're doing the following in pseudocode:
GET /tasks?assignee=...&workspace=...
foreach task
GET /task/.../tags
GET /users/...
So if the user has 20 tasks (and real users typically have a lot more than 20 tasks - if you only care about incomplete and tasks completed in the last, say, week, you could use ?completed_since=<DATE_ONE_WEEK_AGO>), you've made 22 requests. And because it's synchronous, you wait a few seconds for each and every one of those requests before you start the next one.
Fortunately, the API has a parameter called ?opt_fields that allows you to specify the exact data you need. For example: let's suppose that for teach task, all you really want is to know the task ID, the task name, the tags it has and their names. You could then request:
GET /tasks?assignee=...&workspace=...&opt_fields=name,tags.name
(Each resource included always brings its id field)
This would allow you to get, in a single HTTP request, all the data you're after. (Well, the user lookup is still separate, but at least that's just 1 extra request instead of N). For more information on opt_fields, check out the documentation on Input/Output Options.
Hope that helps!
I want to retrieve data from database using mysql in codeigniter/custom php through text from my mobile.
I am student and new developer.
I'm going to try to point you in the right direction although a little research would take you there anyway. You should start by looking for an SMS API in php. A simple google search returns a lot of relevant results.
TextMagic is one such SMS Api and is hosted on https://code.google.com/. It is pretty well documented and quite simple to use:
$api = new TextMagicAPI(array(
"username" => "your_user_name",
"password" => "your_API_password",
));
$text = "Hello world!";
$phones = array(9991234567);
$is_unicode = true;
$api->send($text, $phones, $is_unicode);
So it's just about creating an account and it allows you to receive SMS as well.It all depends on how you want to go about it (if you are looking for a free or paid service and other features that you might want).
Anyway, I hope it gets you started in the right direction.
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