I am using Magento ver. 1.9.2.1.
I don't have any idea to integrate third party api in magento. I have to integrate the api for website.com, for that they provide the login details and a doc.
In that doc, it is mentioned to integrate
1. Search Service Availability API
2. Order Creation API
3. Tracking API
For each above API, they provide code,details and json response.
I have created a user and role from admin. And create a file test.php in root folder and put their code and checked in browser, but it shows blank
Given code in doc for Search Service Availability API:
<?php
ob_start();
error_reporting( 0 );
ini_set('display_errors', 'off');
$pickup_pincode = ‘110001’ // pass pincode
$delivery_pincode =’110001’; // Pass the Parameters Here pincode
$service=’Online’ // Cod or Online
$weight=’1’ // pass weight
$service_name = ‘Standard’ // standard / Priority / Economy
$request_url ='http://avnbiz.co.in/test/AVNBIZ/webservice/test_search_service.php';
$post_data =
'&pickup_pincode=$pickup_pincode&delivery_pincode=$delivery_pincode&weight=$w
eight&service=$service&service_name=$service_name'';
$post = curl_init();
curl_setopt($post, CURLOPT_URL, $request_url);
curl_setopt($post, CURLOPT_POST,TRUE);
curl_setopt($post, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($post, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($post);
curl_close($post);
print_r($response);
$result = json_decode($response, true);
print_r($result);
?>
response
[{"Service Name":"Standard","partner_id":"2","partner_name":"DOT
ZOT","price":"0","status":"PRICE NOT AVAILABLE "},{"Service
Name":"Standard","partner_id":"9","partner_name":"GATI","price":"0","status":"PRICE
NOT AVAILABLE "},{"Service
Name":"Standard","partner_id":"324","partner_name":"Fedex TSCI Pvt
Ltd","price":"50","status":"Success"},{"Service
Name":"Standard","partner_id":"327","partner_name":"GATIKWE EXPRESS PVT
LTD","price":"50","status":"Success"},{"Service
Name":"Standard","partner_id":"335","partner_name":"demo","status":"NO SERVICE
AVAILABLE"}]
If anyone has any idea, please let me know where I am making a mistake.
Related
I am trying to delete all classes from Google Classroom using the API. I call Classes.List to retrieve the ID number of all classes, then pass this to Classes.Delete. However at this point I get a 'Requested entity was not found.' error message.
I am unsure how this returns in the List command but fails on Delete. Are there any prerequisites of the Delete command that I cannot see on the Google documentation?
Same happens on the 'Try This API' section of the Google website, so fairly confident it isn't a code issue.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,
"https://classroom.googleapis.com/v1/courses");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Authorization: Bearer $token",
"Content-Type: application/json"
));
$response = curl_exec($ch);
curl_close($ch);
$response = json_decode($response, true);
foreach ($response['courses'] as $Course)
{
$VLEID=$Course['id'];
$ch1 = curl_init();
curl_setopt($ch1, CURLOPT_URL,
"https://classroom.googleapis.com/v1/courses/".$VLEID);
curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch1, CURLOPT_HTTPHEADER, array(
"Authorization: Bearer $token"
));
$response1 = curl_exec($ch1);
curl_close($ch1);
var_dump($response1);
echo "<br/>";
die();
}
This seems to be bug on Google classroom side. Please see issue logged in GC issue tracker for this around the same time this question was posted here and the issue creator also mentioned it could be regressed issue as same API was returning different number of courses earlier.
https://issuetracker.google.com/issues/134993210
I'm seeing the same problem in my automated test suite. As far as I can tell, some of the courses being returned from Courses.List is returning courses that have already been deleted. I can't do a Course.Get on the id's either, nor do they show in when browsing courses on the Classroom web page. I know it didn't used to do that because this test suite has been around for years, but I hadn't run it recently, so either there has been a regression somewhere on the Google side, or perhaps it just take a while for the delete to fully propagate. I know the distributed nature of some of these services sometimes manifests in (usually) short term inconsistencies.
I would like to return a file in my controller that is downloaded from an API (who needs a basic auth).
This API returns the file and the problem is I can't use ajax because of Access-Control-Allow-Origin, even when I add the basic auth in the header, it returns this error. And I don't have access to this API so I can't change it the config.
So I found another way! I call this API from my controller with the header and the basic auth. It's working! I can access this API and I don't have the error message: Access-Control-Allow-Origin.
But the problem is the API returns heavy files, and I have this exception OutOfMemoryException. It's normal.
So I would like to returns in my controller just a redirect link to this API with the header and basic auth to download the file. Do you think it's possible?
An example of what I want (But it's not working):
public function indexAction()
{
// API
$url = "http://api-who-callback-a-file.com/api/file";
//Create header
$curl = curl_init();
$url = sprintf("%s?%s", $url, http_build_query(false));
// Optional Authentication:
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "admin:admin");
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// Get file (Problem here because the file is to heavy to be downloaded by the server)
$result = curl_exec($curl);
curl_close($curl);
// Return the file
return $this->file($result);
}
In this example, it's not working because the server download the file and it's too heavy. Me I just want to return the URL with the Header to the client, and he will download the file.
Thank you
Please help me in how to create the custom function to search records from custom module in zoho crm.
I am new to zoho crm so I do not have any idea about how to code for this.
The workflow triggers on Event create.
In custom module LEADID is inserted into Lead Id field and I want to search record by Lead Id fields value from custom module.
In function I passed the lead id for search record.
Below is sample code which I create but it does not work .
Lead_id=input.LeadID.toString();
Event_id=input.EventID.toString();
rec = zoho.crm.getRecordById("Events",input.EventID);
resp = zoho.crm.searchRecords("CustomModule1","Lead Id",input.LeadID);
for each ele in resp
{
mp=map();
mp.put("Event Created Time",rec.get("Created Time"));
contactId=ele.get("CUSTOMMODULE1_ID");
updateResp = zoho.crm.updateRecord("CustomModule1",contactId,mp);
}
Here is sample API method using PHP ,code for getting record from Lead module using Lead ID
$auth = "*************************";// Auth Keys
$id="****************";// Record Id
////////////get data by Id from Zoho Lead Module ///////////
$get_url = "https://crm.zoho.com/crm/private/json/Leads/getRecordById?";
$get_query = "authtoken=".$auth."&scope=crmapi&id=".$id."";
$get_curl = curl_init();
curl_setopt($get_curl, CURLOPT_URL, $get_url);
curl_setopt($get_curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($get_curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($get_curl, CURLOPT_TIMEOUT, 60);
curl_setopt($get_curl, CURLOPT_POST, 1);
curl_setopt($get_curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($get_curl, CURLOPT_POSTFIELDS, $get_query);
$get_response = curl_exec($get_curl);
$jfo = json_decode($get_response);
echo "<pre>";
curl_close($get_curl);
print_r($jfo);
I want to create a subgroup that is a subgroup, using API v3, and I'm not sure how to set the condition in the request. For some reason I can't get to the Playground today, so I can't play with it.
I'm thinking something like:
function createSegment($apikey, $dc, $list_id, $name) {
$data = array(
"name"=> $name,
**CONDITION**
);
$data = json_encode($data); // API requires JSON objects
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://".$dc.".api.mailchimp.com/3.0/lists/".$list_id."/segments");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true); // declare request is POST type
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // set POST data
curl_setopt($ch, CURLOPT_USERPWD, "user:".$apikey); // HTML Basic Auth
$output = curl_exec($ch); // execute and capture response
curl_close($ch);
}
This is what the API Support had to say:
With the release of version 3.0 of our API we made some changes to the structure of how we use IDs. In this case there are currently 2 sets of IDs that groups can be referenced by, depending on which version of the API you are using.
In version 2.0, the group ID is an integer and can be retrieved using the /lists/interest-groupings call here:
https://apidocs.mailchimp.com/api/2.0/lists/interest-groupings.php
With version 3.0, the group ID is a hash and is returned by making a GET request to the Lists Interest Collection endpoint here:
http://kb.mailchimp.com/api/resources/lists/interest-categories/interests/lists-interests-collection
When creating a segment however, we currently only accept the group ID returned in version 2.0 of the API, regardless of whether that segment call is being made with 2.0 or 3.0. For this reason, when segmenting by groups, a call would need to be made to the 2.0 endpoint to retrieve those groups IDs. These IDs are static though, so if they are expected to be updated, they would only need to be requested once and can then be stored locally.
I got this strange problem for long and have been trying to solve it without any success.
I got a CI site based on CI 1.7.2. It works fine for most of the time. But many a time it does not.
The problem is, we fill up up a form with many fields and submit it to a method in the controller which does the checking. It then posts the data to the third party web service using curl.
I have a error/order response tracker setup, which mails me every time I get response back from the API. The mail content is of the format:
Order ID: 5876 Result length - 8056 or
Order ID: 5877 Result length - 1121 ....and so on for each order.
Now, many a time I get mail like:
Order ID: Result length - 34441 (Please note the order id is missing here)
Order ID: Result length - 9700
Now , the code for my mail happens to be
mail('myemail#xyz.com','Order ID: '.$this->session->userdata('SITE_ORDER_NO').' Result length - '. $lengthResponse , $orderResult, $headers);
So its seems the,
$this->session->userdata('SITE_ORDER_NO')
segment of the code does not have the Order ID any more. As such the API response is not getting saved in the database . Also I got few reports that the user was logged out of the website after it transferred him to the next page , after the response came back.
My session setup is:
$config['sess_cookie_name'] = 'cisessionJHGJHSOMECAPITALLETTERS';
$config['sess_expiration'] = 7200;
$config['sess_encrypt_cookie'] = TRUE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'user_sessions';
$config['sess_match_ip'] = TRUE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
The code of the helper function is:
function call_order_curl($postVars){
$posturl = "API_URL";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $posturl);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,300);
curl_setopt($ch,CURLOPT_TIMEOUT,600);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postVars);
curl_setopt($ch, CURLOPT_POST, 1);
$response = curl_exec($ch);
return $response;
}
I would really appreciate any help on this. Thank you.