How to write ensembl rest api in PHP? - php

Ensembl is a collection of genome database and annotation source for many eukaryotic genome. They have created REST API interface for user to access their data. http://rest.ensembl.org/. Also, provide detailed steps to write our own client ( perl, python etc.). I am learning PHP and hence would like to write PHP client, any suggestion will be helpful. Are there any libraries or class that I can use to effectively implement the client and access specific data and display back on html? Below is what I tired so far and work in progress.
$server = "http://grch37.rest.ensembl.org";
$ext = "/vep/human/hgvs/";
$hgvs_notation = "AGT:c.803T>C?content-type=application/json";
# added the application header
$url = $server.$ext.$hgvs_notation;# updated based on comment
$response = file_get_contents($url);
$data = json_decode($response, true);
print_r($data);

Related

Google API Data Transfer Insert: missing resource.applicationDataTransfer

I'm creating simple PHP script for transfering ownerships of drive files between users in the same domain. I want to use Admin SDK Transfers and Insert method.
Google has documentation about transfers here
I tried to transfer data through their webpage GUI and it went fine. What I can't do is how to make it work with PHP Client library.
Let's say I have prepared object for creating requests to Transfers resource
$transfers = new \Google_Service_DataTransfer($googleConnection);
googleConnection handles service account authorization so i can make requests like this:
$data = $this->transfers->transfers->listTransfers();
This returns data of all existing transfers in domain. Based on documentation and PHP Client library insert operation should work also.
$transferParams = new \Google_Service_DataTransfer_ApplicationTransferParam();
$transferParams->setKey("PRIVACY_LEVEL"); //what kind of docs I want to transfer
$transferParams->setValue(['SHARED', 'PRIVATE']);
$appDataTransfer = new \Google_Service_DataTransfer_ApplicationDataTransfer();
$appDataTransfer->setApplicationTransferParams($transferParams);
$appDataTransfer->applicationId = "iDString"; //set application ID
$newTransfer = New \Google_Service_DataTransfer_DataTransfer();
$newTransfer->setOldOwnerUserId('accountID'); //origin account IDs are placeholders
$newTransfer->setNewOwnerUserId('account2ID'); //destination account
$newTransfer->setApplicationDataTransfers($appDataTransfer);
$result = $this->transfers->transfers->insert($newTransfer); //execute insert
After executing insert I am getting code 400 with message Missing required field: [resource.applicationDataTransfer].
If I test real parameters via web they work.
I must be missing something, because that exception doesn't make sense at all.
I'm also open to alternative solutions.
setApplicationDataTransfers method expects an array of Google_Service_DataTransfer_DataTransfer so you just need to update the following line (note the [] in the params)
$newTransfer->setApplicationDataTransfers([$appDataTransfer]);

EBS payment gateway: encoded response

EBS can return the response parameters as single GET parameter when the return url is specified as 'http://www.yourdomainname.com/response.extension?DR={DR}' as described in knowledgeable.
However I can not find the specification how to decrypt and validate the response. Also the Integration guide (v.3) does not contain any information on the subject.
I have found few examples which uses this options and decrypts their response via custom RC43 decoder.
With the DR variable specified the response contains single encoded/encrypted string.
However the I am unable to recognise what sort of algorithm is actually used (I suspect RC4 stream cyphers) and most examples ends with the decryption (without actual validation).
I am looking for any information on the subject.
The integration kits actually provide a way How to use and decode the response. However not all kits use this or verify the response at all.
To use the encrypted response the return url must complain the following format as specified in knowledgebase: 'http://www.yourdomainname.com/response.extension?DR={DR}'
$DR = preg_replace("/\s/","+",$_GET['DR']);
$rc4 = new Crypt_RC4($secret_key);
$QueryString = base64_decode($DR);
$rc4->decrypt($QueryString);
$QueryString = explode('&',$QueryString);
$response = array();
foreach($QueryString as $param){
$param = explode('=',$param);
$response[$param[0]] = urldecode($param[1]);
}
return $response
The Crypt_RC43 class which actually takes care of the decryption is then provided by EBS inside of Rc43 file which is part of the integration kits.
Note: As I have stated the Rc43 file is not part of every integration kit. Some kits even includes the Crypt_RC43 class as a private inner class of the controller. For mine implementation I have used the Rc43 file contained in Wordpress-3.7.x Donate integration kit.

how to use GET to obtain info from a URL

I'm a php programmer but I'm new to APIs.
I would like to run a mysql query to get info from an XML document from madmimi.com.
documentation from madmimi.com says
GET http://madmimi.com/audience_lists/lists.xml will return the data I need. I've created a php file and connected to their API using
require(dirname(FILE) . '/MadMimi.class.php');
$mailer = new MadMimi('username', 'password');
but I don't understand how to use GET to connect to the URL and display the XML info?
What do I need to do?
All http api interaction is hidden to you behind their library. You can use it's methods to grab objects, like this to lists:
$mailer->Lists();
There is no complete documentation, but you can read raw code to search urls, described in API for finding appreciated methods.
You can use curl to get the response from the 3rd party api. Have a look at this answer:
https://stackoverflow.com/a/5159513/1369567
Based upon the code in answer given at that link, you may need to the code to match your request. E.g:
/* Script URL */
$url = 'http://madmimi.com/audience_lists/lists.xml';
/* $_GET Parameters to Send */
$params = array('username' => '*your api username*', 'password' => '*your api password*');

Facebook PHP API not always returning event venue data

I have 3 events:
https://www.facebook.com/491594114271958 (Mad Haus)
https://www.facebook.com/569226999799343 (Deuglish)
539504962802119/ (Piffle)
All are being fetched via the PHP
$config = array();
$config['appId'] = $appId;
$config['secret'] = $secret;
$config['fileUpload'] = false; // optional
$facebook = new Facebook($config);
$ev = $facebook->api('/'.$id."?fields=cover,description,location,name,owner,venue",'GET');
print_r($ev);
For some reason Mad Haus and Piffle do not return venue data but Deuglish does. All events return basic data such as title, description and start time. When I run them through the Graph API explorer the venue data is returned as expected but not through the PHP API, any ideas? I can not for the life of me see the difference with these 3 events.
Thanks,
Caroline
Well, if you don't want to wait for the Facebook developers to fix the bug, you can try the same by making a simple GET request (of course along with an Access Token) to Graph API using PHP cURL. Since you are able to retrieve the venues while using the Graph API explorer, I'm pretty sure you'll be able to get them by making a simple GET request using PHP cURL.
This however involves an overhead of parsing the received JSON object and dealing with errors will be a little difficult here. But you can give it a shot.

How to create a webservice for the conversion rate

I would like to create a SOAP Web service for the followıng wsld
http://www.webservicex.com/CurrencyConvertor.asmx?WSDL
Could you please explain how to do this?
The following code is not working... Please help me..
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient("http://www.webservicex.com/CurrencyConvertor.asmx?wsdl");
$CURR = array("FromCurrency" => "USD","ToCurrency" => "INR");
$scramble = $client->ConversionRate($CURR);
$mirror = $client->ConversionRateResponse($scramble);
Thanks,
Praveen J
Let's start with your client URL:
http://www.webservicex.com/CurrencyConvertor.asmx?wsdl
This is wrong. The ?WDSL URL is NOT the URL you use for CALLING the web service, it is the URL you use to retrieve the WDSL that describes the web service. THis is used by automatic tools to generate a wrapper.
http://www.webservicex.com/CurrencyConvertor.asmx
is the "real" URL that you use to execute operations.
http://www.webservicex.com/CurrencyConvertor.asmx?op=ConversionRate
Has a more invormation on the conversion per se, including the exact parameters with naming you need for the Post and GET operations, including examples.

Categories