I want to use VirusTotal as way that they wrote in their websites.
<?php
$virustotal_api_key = '9491e275f708f55b0777b495411556c916afdda7255d4614500d4aed27175001';
$scan_url = 'https://www.google.com/';
$post = array('apikey' => $virustotal_api_key,'url'=> $scan_url);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.virustotal.com/vtapi/v2/url/scan');
curl_setopt($ch, CURLOPT_POST, True);
curl_setopt($ch, CURLOPT_VERBOSE, 1); // remove this if your not debugging
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,True);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result=curl_exec ($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
print("status = $status_code\n");
if ($status_code == 200) { // OK
$js = json_decode($result, true);
print_r($js);
} else { // Error occured
print($result);
}
curl_close ($ch);
?>
But I always return error as:
status = 0
I have been searching a lot and still found nothing!!!
I very appreciate if u help me out.
tnx.
I have figured out what was the problem.
This is because thier website banned my country(Iran) IPs.
I wasted my time from morning to noon to found this out :( :(
I should search for something else like this.
Related
I am trying to update a LEAD using this URL
$lead_url = ‘https://’.$company_domain.’.pipedrive.com/api/v1/leads/’ . $leadID . ‘?api_token=’ . $PD_API_KEY;
But it returns 404 Not Found. When I check this URL in the browser it returns the complete information of that lead.
Here is my Curl Code:
function pipedrive_update_curl($arr , $endpoint)
{
$response = array();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $endpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($arr));
//***//
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
//**//
$response_result = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curl_errors = curl_error($ch);
curl_close($ch);
$response['error'] = $curl_errors;
$response['status'] = $status_code;
$response['response'] = $response_result;
return $response;
}
Can somebody please explain where I am going wrong?
PUT method for updating leads is not supported.
see docs and pipedrive community posts:
https://developers.pipedrive.com/docs/api/v1/Leads#updateLead
https://devcommunity.pipedrive.com/t/put-not-working-when-updating-a-lead/3629
I want to get page status code.
Url address has a port and after that alias:
http://93.184.216.xxx:3000/status
I tried this this:
function status($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, true); // we want headers
curl_setopt($ch, CURLOPT_NOBODY, true); // we don't need body
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT,10);
$output = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpcode == 200) { return '<span class="green-link">ONLINE</span>';}
else {
return '<span class="red-link">'.$httpcode.'</span>';}
}
But this is useless, I'm always get status 0.
Can anybody have better idea?
Thanks
Can anyone help to get access token by using Flipkart app id and app secret.
We have tried with the code below:
<?php
$username='appid';
$password='appsecret';
$url='https://api.flipkart.net/oauth-service/oauth/token\?grant_type\=client_credentials\&scope=Seller_Api';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
$output = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get status code
$info = curl_getinfo($ch);
curl_close($ch);
if(curl_errno($ch)){
echo 'Curl error: ' . curl_error($ch);
}
print_r($output);
echo $status_code;
But we get the error:
{"error":"invalid_grant","error_description":"Unauthorized grant type: client_credentials"} 400
I ran through the same issue and after struggling for a couple of hours I went to my seller account and recreated my "Application Id" and "Application Secret". The only difference I made was I selected "self_access_application" instead of "third_party_application" this time and I was good to go.
Please refer: https://nimb.ws/sziWmA
Hope this helps
Thanks
You can try this code, i also faced the same issue.
$url = "https://api.flipkart.net/oauth-service/oauth/token?grant_type=client_credentials&scope=Seller_Api";
$curl = curl_init();
curl_setopt($curl, CURLOPT_USERPWD, config('constants.flipkart.application_id').":".config('constants.flipkart.secret_key'));
curl_setopt($curl, CURLOPT_URL,$url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($curl);
$token = json_decode($result,true);
if(isset($token['access_token'])){
$this->access_token = $token['access_token'];
}
you can try this it will be helpful python/odoo developer
def flipkart_token_generation(self):
if not self.flipkart_sandbox_app_id or not self.flipkart_sandbox_cert_id:
raise UserError(_("Flipkart: cannot fetch OAuth token without credentials."))
else:
url = "https://sandbox-api.flipkart.net/oauth-service/oauth/token"
data = {'grant_type': 'client_credentials', 'scope': 'Seller_Api'}
response_json = requests.get(url, params=data, auth=(self.flipkart_sandbox_app_id, self.flipkart_sandbox_cert_id)).json()
self.env['ir.config_parameter'].sudo().set_param('flipkart_sandbox_token', response_json["access_token"])
I'm pretty new to the BoxBilling Licensing and to be fair, their not really providing any support!
I have this code to check a license which is working correctly however, if the license is invalid, it simply shows the word "Array" and if it is valid, shows nothing at all.
I need to know how I can set a different message rather than "Array" if the license is invalid and how I can basically kill the page (via die() or something similar).
Thanks in advance for your help guys!
<?php
include("config.php");
include("opendb.php");
function getLicenseDetails($key)
{
$systeminfo = mysql_query("SELECT * from `systeminfo`");
$systeminfo = mysql_fetch_array($systeminfo);
$url = 'http://clients.pbtechsupport.com/index.php/api/guest/servicelicense/check';
$params = array();
$params['license'] = $systeminfo[licensekey];
$params['host'] = 'localhost';
$params['path'] = dirname(__FILE__);
$params['version'] = '1.0';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
$result = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($code != 200) {
error_log('CURLINFO_HTTP_CODE: '.$code);
}
return json_decode($result, true);
}
$json = getLicenseDetails('test');
if(!$json['valid']) {
print $json['error'];
}
include("closedb.php");
?>
print_r($json['error']) to see what's in the array, then use its contents to output something more intelligent based on that. They presumably are returning information about the particular error encountered in their JSON.
Based on your comment, doing print $json['error']['message']; will display the error encountered. You could also do if($json['error']['code'] == 1006) { print 'Your own custom error about the license here.'; } if you'd prefer not to use their own text.
I am using a simple cURL statement to parse XML on my site. When the API is up and working it works fine, however as soon as the API does down for any reason the entire site crashes.
$url = 'http://www.mydomain.com/webservicexample';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
curl_close($ch);
$xml = new SimpleXmlElement($data);
Is there a conditional I can put around the url so that it only carries out the cURL script if there's a positive response from the API? I tried the following but it didn't work because it never got a server response to give any headers:
$url_headers = #get_headers($url);
if($url_headers[0] == 'HTTP/1.1 200 OK') {
// do script
}
Any help/advice much appreciated!
You can check the return value of curl_exec():
if (false === ($data = curl_exec($ch))) {
die("Eek! Curl error! " . curl_error($ch));
}
And check the response headers too:
if (200 !== (int)curl_getinfo($ch, CURLINFO_HTTP_CODE)) {
die("Oh dear, no 200 OK?!");
}
In the end I was able to get it working by setting a timeout time with CURLOPT_TIMEOUT and CURLOPT_CONNECTTIMEOUT and then put a conditional around it using curl_errno().
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
$data = curl_exec($ch);
if(!curl_errno($ch))
{
curl_close($ch);
$xml = new SimpleXmlElement($data);
return $xml;
}