I have seen little to know instruction on using php to develop a client website to make remote calls to JiRA.
Currently I'm trying to make a soap client using JSP/Java to connect to a local jira instance. I would like to create and search issues that is all. We are currently having some problems using Maven2 and getting all the files we need from the repository since we are behind a major firewall(yes I've used the proxy).
I have a lot of experience with PHP and would like to know if using the PHP soapclient calls can get the job done.
http://php.net/manual/en/soapclient.soapclient.php
Yes it can be done, using SOAP or XML-RPC.
Using the APIs is pretty much straight forward - have a look at the API documentation to find the right functions for you. your code should look something like :
<?
$soapClient = new SoapClient("https://your.jira/rpc/soap/jirasoapservice-v2?wsdl");
$token = $soapClient->login('user', 'password');
...
... # get/create/modify issues
...
?>
Example of adding a new comment:
$issueKey = "key-123";
$myComment = "your comment";
$soapClient = new SoapClient("https://your.jira/rpc/soap/jirasoapservice-v2?wsdl");
$token = $soapClient->login('user', 'password');
$soapClient->addComment($token, $issueKey, array('body' => $myComment));
Example of creating an issue:
$issue = array(
'type'=>'1',
'project'=>'TEST',
'description'=>'my description',
'summary'=>'my summary',
'priority'=>'1',
'assignee'=>'user',
'reporter'=>'user',
);
$soapClient = new SoapClient("https://your.jira/rpc/soap/jirasoapservice-v2?wsdl");
$token = $soapClient->login('user', 'password');
$soapClient->createIssue($token, $issue);
Note that you need to install php-soap in linux (or it's equivalent in windows) to be able to use the SOAP library.
Related
I am using this PHP Kafka client library. Our Kafka is installed on server A and producer from different servers adding data in this using Java code, and now I am trying to consume data via PHP from server B. I need to pass the username and password to access data but in documentation, I am not getting any way to pass the username, password, and bootstrap server.
Java team using following details to add data in kafka
spring.kafka.bootstrap-servers=<value-here>
spring.kafka.properties.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username='<username>' password='<password>';
Now same, I am trying to achieve via PHP. How I can pass these parameters with my PHP code to consume data.
According to the documentation, try to do:
<?php
$conf = new \RdKafka\Conf();
$conf->set('sasl.jaas.config', "org.apache.kafka.common.security.plain.PlainLoginModule required username='<username>' password='<password>'");
$conf->set('security.protocol', "SASL_SSL");
$conf->set('sasl.mechanism', "PLAIN");
$consumer = new \RdKafka\Consumer($conf);
$consumer->addBrokers("<kafka_servers_list>");
Following is the solution of problem.
$conf = new RdKafka\Conf();
$conf->set('bootstrap.servers', '<pass-server-here>');
$conf->set('sasl.username', '<username>');
$conf->set('sasl.password', '<password>');
$conf->set('security.protocol', 'sasl_ssl');
$conf->set('sasl.mechanism', 'PLAIN');
$conf->set('group.id', 'anygroupID');
$conf->set('debug', 'all');
$rk = new RdKafka\Consumer($conf);
I want to scrape a site with the symfony panther package within a Laravel application. According to the documentation https://github.com/symfony/panther#a-polymorphic-feline I cannot use the HttpBrowser nor the HttpClient classes because they do not support JS.
Therefore I try to use the ChromClient which uses a local chrome executable and a chromedriver binary shipped with the panther package.
$client = Client::createChromeClient();
$crawler = $client->request('GET', 'http://example.com');
dd($crawler->html());
Unfortunately, I only receive the empty default chrome page as HTML:
<html><head></head><body></body></html>
Every approach to do something else with the $client or the $crawler-instance leads to an error "no nodes available".
Additionally, I tried the basic example from the documentation https://github.com/symfony/panther#basic-usage --> same result.
I'm using ubuntu 18.04 Server under WSL on Windows and installed the google-chrome-stable deb-package. This seemed to work because after the installation the error "the binary was not found" does not longer occur.
I also tried to manually use the executable of the Windows host system but this only opens an empty CMD window always reopened when closing. I have to kill the process via TaskManager.
Is this because the Ubuntu server does not have any x-server available?
What can I do to receive any HTML?
So, I'm probably late, but I got the same problem with a pretty easy solution: Just open a simple crawler with the response content.
This one differs from the Panther DomCrawler especially in methods, but it is is safer to evaluate HTML structures.
$client = Client::createChromeClient();
$client->request('GET', 'http://example.com');
$html = $client->getInternalResponse()->getContent();
$crawler = new Symfony\Component\DomCrawler\Crawler($html);
// you can use following to get the whole HTML
$crawler->outerHtml();
// or specific parts
$crawler->filter('.some-class')->outerHtml();
$client = Client::createChromeClient();
$crawler = $client->request('GET', 'http://example.com');
/**
* Get all Html code of page
*/
$client->getCrawler()->html();
/**
* For example to filter field by ID = AuthenticationBlock and get text
*/
$loginUsername = $client->getCrawler()->filter('#AuthenticationBlock')->text();
I am feebly trying to implement a stamps.com api interface into my platform. This is my first time using SOAP, I event had to recompile PHP to enable the libraries.
I'm moving along but now I'm having a problem. They support soap 1.1 and soap 1.2 requests, and when I run the following code:
$client = new SOAPClient(
'./SWSIM.wsdl',
array(
'trace' => 1
)
);
I get back a successful response from my request that comes after this.
However if I add the option to use soap 1.2 like this:
$client = new SOAPClient(
'./SWSIM.wsdl',
array(
'trace' => 1,
'soap_version' => SOAP_1_2
)
);
I get the following error:
There was an exception running the extensions specified in the config file. ---> Value cannot be null. Parameter name: input
This line is not actually throwing the exception. Its the following command that throws it, but removing the soap_version is what "fixes it". I would like to use soap 1.2 so naturally this is bugging me.
FTR The command I'm running is this:
$authData = array(
"Credentials" => array(
"IntegrationID" => "MYUID",
"Username" => "MYUSERNAME",
"Password" => "MYPASSWORD"
)
);
try {
$objectresult = $client->AuthenticateUser($authData);
} catch (Exception $e) {
echo "EXCEPTION: " . $e->getMessage();
print_r($e);
exit;
}
The WSDL file can be viewed here:
https://swsim.stamps.com/swsim/swsimv22.asmx?wsdl
I have also checked in with their developer support and they said:
"The message you are currently receiving is returned from whichever program you are designing your integration with. This has been commonly noted happening within Visual Basic where is creates a wrapper class that needs certain variables for the response. This could be similar to the behavior that you are experiencing. Please verify how your program language consumes a WSDL."
I also noticed that the __soapCall method excepts an "input headers" argument. I'm not entirely sure I should be / can even use that method in my code. I suppose I should just try and play with it.
Check your WSDL file. I was using the wrong one, and it appears you may be as well. Try this one: http://developer.stamps.com/developer/downloads/files/Stamps.com_SWSIM.wsdl
NOTE: The above is out of date. Contact stamps.com for the current wsdl!
I know this is an old thread, but here is an example class that should get anyone started with the stamps.com api in php https://github.com/aaronjsmith/stamps.com-php
The WSDL looks fine and it's the same input structure for both Soap versions. The problem is a bug somewhere at their end, you'll have to contact them to resolve.
I would also test it via a .NET app just to see if it behaves the same.
I am using the following code to read attendance data from a biometric device:
<?php
$options = array(
'location' => 'http://192.168.1.178/iWsService',
'uri' => 'http://www.zksoftware/Service/message/'
);
$client = new SoapClient(null, $options);
$soapRequest = "<GetAttLog><ArgComKey xsi:type=\"xsd:integer\">0</ArgComKey><Arg><PIN xsi:type=\"xsd:integer\">All</PIN></Arg></GetAttLog>";
$response = $client->__doRequest($soapRequest, 'http://192.168.1.178/iWsService', '', '1.1');
echo '<pre>', var_dump(htmlspecialchars($response, ENT_QUOTES)), '</pre>';
?>
This just works fine. But since we do not have the documentation/manual/API Reference for this particular device (and nowhere available), I have no clue on what other functions are available in this machine.
Is there any luck finding out what other SOAP parameters this device could accept?
Your help would be really valuable at this moment. Thank you!
At last I found the SOAP SDK Manual of zksoftware.
Since I was searching for the manual for almost a year, I am uploading it to my server for the benefit of future users:
http://www.myfurni.com/downloads/zksoftware_SOAPSDKManual.pdf
Edit:
The above link doesn't work anymore. Here is the new one:
https://drive.google.com/file/d/0ByvozREXZpckcHlHYnZoOTMtWjg/view?usp=sharing
I don't think it is possible. WSDL is the source of information about functions and arguments. No WSDL - no function list.
Try this It uses the UDP protocol to communicate to the Attendance Machine.
Does anyone know of an open source PHP class (preferably BSD or MIT license) that will interface with the MS Exchange Server 2007 Web Services via. SOAP?
I am looking for a higher level class that has functionality for sending messages via. the web service.
I had this same problem, so I started building something, here:
https://github.com/rileydutton/Exchange-Web-Services-for-PHP
It doesn't do much yet (basically just lets you get a list of email messages from the server, and send email), but it would be good enough to use as a basic starting point for doing some more complicated things.
I have abstracted out a good bit of the complexity that you would have to slog through using php-ews. If you are looking to do some raw, powerful commands with the server, I would use php-ews...this is for folks who just happen to be working with an Exchange server and want an easy way to do some basic tasks.
Oh, and it is MIT licensed.
Hope that someone finds it useful!
Here is a class that you need: php-ews (This library makes Microsoft Exchange 2007 Web Services easier to implement in PHP).
You could find it at: http://code.google.com/p/php-ews/
There is only one example but that should give you the way to implement it.
Below you can find an implementation in order to:
connect to server
get the calendar events
Note: don't forget to fill-in blank variables. You would also need to include php-ews classes files (I used the __autoload PHP function).
$host = '';
$username = '';
$password = '';
$mail = '';
$startDateEvent = ''; //ie: 2010-09-14T09:00:00
$endDateEvent = ''; //ie: 2010-09-20T17:00:00
$ews = new ExchangeWebServices($host, $username, $password);
$request = new EWSType_FindItemType();
$request->Traversal = EWSType_FolderQueryTraversalType::SHALLOW;
$request->CalendarView->StartDate = $startDateEvent;
$request->CalendarView->EndDate = $endDateEvent;
$request->CalendarView->MaxEntriesReturned = 100;
$request->CalendarView->MaxEntriesReturnedSpecified = true;
$request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::ALL_PROPERTIES;
$request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::CALENDAR;
$request->ParentFolderIds->DistinguishedFolderId->Mailbox->EmailAddress = $mail;
$response = $ews->FindItem($request);
echo '<pre>'.print_r($response, true).'</pre>';
Exchange server supports WebDAV:
http://www.troywolf.com/articles/php/exchange_webdav_examples.php
If all you want to do is send messages, you could just use SMTP:
http://ca2.php.net/manual/en/book.mail.php
I have been researching this same issue and I have yet to find a class specific to MS Exchange. However, if you feel up to learning and building the XML yourself, you may want to have a look at the NTLM SOAP classes at http://rabaix.net/en/articles/2008/03/13/using-soap-php-with-ntlm-authentication. This will allow you to authenticate against Active Directory to make your SOAP calls, which native PHP SOAP does not allow you to do. Another decent resource that uses the same method to connect to MS CRM is http://www.reutone.com/heb/articles_internet.php?instance_id=62&actions=show&id=521.
The examples under http://www.troywolf.com/articles/php/exchange_webdav_examples.php are for Exchange 2003 not 2007.