I am working on a webhook to notice when an order gets updated.
My webhook function looks like this:
public function webhook(Request $request) {
if(!empty(Request::header('x-wc-webhook-delivery-id'))) {
$head = Request::header('x-wc-webhook-source');
$site = preg_replace('{/$}', '', $head);
$webhookId = Request::header('x-wc-webhook-id');
$deliveryId = Request::header('x-wc-webhook-delivery-id');
$this->webhookOrders($site, $webhookId, $deliveryId);
}
}
So it will fire the webhookOrders function which is only getting the updated order by WebhookId & deliveryId:
$delivery = $woocommerce->get('webhooks/'.$webhookId.'/deliveries/'.$deliveryId);
Although the strange part is that when I try to access this get request through the webhook it is showing me an empty response:
Array
(
[id] => 559
[duration] =>
[summary] =>
[request_method] =>
[request_url] => https://<my_platform>/api/v1/orders/create
[request_headers] =>
[request_body] =>
[response_code] =>
[response_message] =>
[response_headers] =>
[response_body] =>
[date_created] => 2018-02-28T10:48:05
[_links] => Array
(
[self] => Array
(
[0] => Array
(
[href] => https://<my_woo_site>/wp-json/wc/v1/webhooks/0/deliveries/559
)
)
[collection] => Array
(
[0] => Array
(
[href] => https://<my_woo_site>/wp-json/wc/v1/webhooks/0/deliveries
)
)
[up] => Array
(
[0] => Array
(
[href] => https://<my_woo_site>/wp-json/wc/v1/webhooks/0
)
)
)
)
While in the Woocommerce admin panel it is showing me that there is content:
Also, the thing what's driving me crazy is that when I access the URL outside the webhook it is showing me the content. And the log files are not showing any error.
Hope someone knows the problem. Thanks!
Found the problem:
deliveries are not logged any more.
#deprecated 3.3.0 Webhooks deliveries logs now uses logging system.
Related
I am working a smole project airport search using Rapidapi but
i can't display json data from API in my codeigniter view. i'm googling meany time but not perfect result. please help
here is my json output
HttpResponse Object
(
[code:HttpResponse:private] => 200
[raw_body:HttpResponse:private] => [{"airportId":"6f576bf7-090a-46e3-be70-6d8a55275e04","code":"YYZ","name":"Toronto, Ontario","location":{"longitude":-79.63083299999998,"latitude":43.677222},"cityId":"8f65ce90-aafb-42b4-8185-ae4f1b131889","city":"Toronto","countryCode":"CA","themes":[],"pointsOfSale":["CA"]}]
[body:HttpResponse:private] => Array
(
[0] => stdClass Object
(
[airportId] => 6f576bf7-090a-46e3-be70-6d8a55275e04
[code] => YYZ
[name] => Toronto, Ontario
[location] => stdClass Object
(
[longitude] => -79.630833
[latitude] => 43.677222
)
[cityId] => 8f65ce90-aafb-42b4-8185-ae4f1b131889
[city] => Toronto
[countryCode] => CA
[themes] => Array
(
)
[pointsOfSale] => Array
(
[0] => CA
)
)
)
)
my Controller
public function AirportSearch_form(){
$url="https://cometari-airportsfinder-v1.p.rapidapi.com/api/airports/by-code?code=yyz";
$response = $this->unirest->get($url, $headers = array("X-Mashape-Key" => "ced348bae5mshd648601c9de77cbp1e2dcejsn222973a7564d", "X-Mashape-Host" => "cometari-airportsfinder-v1.p.rapidapi.com"));
//echo'<pre>';
//print_r($response);
//exit();
$jdata=json_decode($response);
$app_title=$this->SuperAdmin_model->AppDataShow();
$data['title']=$app_title->app_title;
$data['menu_col']='';
$this->load->view('agent/header',$data);
$this->load->view('flight/airport_search',$jdata);
$this->load->view('agent/footer',$data);
}
you have both json and non-json versions retrieved. as the latter doesn't require decoding i suggest you use that.
it seems like you can do $response->body[0] to get the array.
and specific items via $response->body[0]->name .etc.
I'm using php and got output from JIRA API like below which connects to tool using https://github.com/chobie/jira-api-restclient/blob/master/README.md. It fetches records very fine but i just want few information from all records so written below code with print_r($issue['description']) but it throws error:
Uncaught Error: Cannot use object of type chobie\Jira\Issue as array
What changes do I need to make in place of $issue to get these 3 information - [id:protected], [description] and [name].
How do I count total bugs found for e.g. number of chobie\Jira\Issue Object found?
Code:
$walker = new Walker($api);
$walker->push(
'project = "SEA" AND (status != "closed" AND status != "resolved") ORDER BY priority DESC'
);
foreach ( $walker as $issue ) {
print "<pre>";
print_r($issue);
print "</pre>";
}
So $issue prints everything like below but i just want to get [id:protected], [description] and [name]. What changes i need to make in place of $issue to get these 3 information. Can someone please give me some hint?
JSON:
chobie\Jira\Issue Object
(
[id:protected] => 21373505
[self:protected] => https://test.corp.com/rest/api/2/issue/21373505
[key:protected] => S12E-7337
[fields:protected] => Array
(
[Status] => Array
(
[self] => https://test.corp.com/rest/api/2/status/3
[description] => Working on the issue
[iconUrl] => https://test.corp.com/images/icons/statuses/assigned.png
[name] => In Progress
[id] => 3
[statusCategory] => Array
(
[self] => https://test.corp.com/rest/api/2/statuscategory/4
[id] => 4
[key] => indeterminate
[colorName] => yellow
[name] => In Progress
)
)
)
chobie\Jira\Issue Object
(
[id:protected] => 74534233
[self:protected] => https://test.corp.com/rest/api/2/issue/74534233
[key:protected] => ASE-7327
[fields:protected] => Array
(
[Status] => Array
(
[self] => https://test.corp.com/rest/api/2/status/3
[description] => This issue is being actively worked on at the moment by the assignee.
[iconUrl] => https://test.corp.com/images/icons/statuses/assigned.png
[name] => In Progress
[id] => 3
[statusCategory] => Array
(
[self] => https://test.corp.com/rest/api/2/statuscategory/4
[id] => 6
[key] => indeterminate
[colorName] => yellow
[name] => In Progress
)
)
)
Got a answer, you need to convert object to array first, get array fields and parse it accordingly.
$walker = new Walker($api);
$walker->push('project = "SEA" AND (status != "closed" AND status != "resolved") ORDER BY priority DESC');
foreach ( $walker as $issue ) {
$issue = $bugs->getFields();
print "<pre>";
print_r($issue);
print_r(trim($issue['Status']['name']);
print "</pre>";
}
im getting this following response from a REST call I made
The Response
Delighted\Person Object ( [__data:protected] => Array (
[id] => 86214536
[name] =>
[email] => hammad+2#ekuep.com
[survey_scheduled_at] => 1473077458
[properties] => Array ( )
) )
I stored it in the $response variable
How can I acces the id
I'm trying to get the last posts of a subreddit - I'm using the jcleblanc reddit sdk (https://github.com/jcleblanc/reddit-php-sdk) and I don't know why It's not working - I receive the following message ewhen I try to acess my website
403 Forbidden
Request forbidden by administrative rules.
The https://ssl.reddit.com/prefs/apps is configured okay - I just don't know why It's not working. I'm using the following function:
<?php
$reddit = new reddit();
$response = $reddit->getListing("calculus", 5);
print $response
?>
It'd be nice to have some help - I'm not any expert developer, just trying to make something.
Thanks :-)
Hey guys - I managed to get it working using an old version of that don't uses OAuth.
$reddit = new reddit($USER, $PASS);
print_r($reddit);
print_r($reddit->getListing("calculus", 1));
It's working! but, on the page I receive all the information, for example:
reddit Object ( [kind] => Listing [data] => stdClass Object ( [modhash] => jvfddbr7sg6a1787beebf94c0a61cc4c2be6e5fb2106da9f4b [children] => Array ( [0] => stdClass Object ( [kind] => t3 [data] => stdClass Object ( [domain] => self.leagueoflegends [banned_by] => [media_embed] => stdClass Object ( ) [subreddit] => leagueoflegends [selftext_html] => [selftext] => [likes] => [user_reports] => Array ( ) [secure_media] => [link_flair_text] => [id] => 2papx0 [gilded] => 0 [secure_media_embed] => stdClass Object ( ) [clicked] => [report_reasons] => [author] => Azberg [media] => [score] => 2217 [approved_by] => [over_18] => [hidden] => [thumbnail] => self [subreddit_id] =>
I'd like to know how can I select only some of the items abovve - like domain, or likes, or anything. I tried but I can't manage it to work. Sorry for the newbiness - I really tried to fix this.
Thanks in advvance!
You should always use the latest API. Anyways, did you fill out the information in config.php?
According to the documentation, you have to "post the key and secret into the appropriate sections" in your config.php which is this file:
https://github.com/jcleblanc/reddit-php-sdk/blob/master/config.php
Specifically these two variables
...
static $CLIENT_ID = 'YOUR CLIENT ID';
static $CLIENT_SECRET = 'YOUR CLIENT SECRET';
...
First, I'm using sugarcrm pro 6.5 and accessing via rest v4, so I have this array that's being returned from printing $results that is working fine:
stdClass Object
(
[result_count] => 2000
[total_count] => 3390
[next_offset] => 2000
[entry_list] => Array
(
[0] => stdClass Object
(
[id] => 77da301b-83dd-4fe6-e38f-53ba151fb084
[module_name] => Leads
[name_value_list] => stdClass Object
(
[id] => stdClass Object
(
[name] => id
[value] => 77da301b-83dd-4fe6-e38f-53ba151fb084
)
[name] => stdClass Object
(
[name] => name
[value] => Jim Beam
)
[status] => stdClass Object
(
[name] => status
[value] => Dead
)
[website] => stdClass Object
(
[name] => website
[value] => website.com
)
[phone_cr] => stdClass Object
(
[name] => phone_cr
[value] => 1-888-888-8888
)
)
)
[1] => stdClass Object
(
[id] => d0ecc069-d556-98f3-41f2-53ba1468327a
[module_name] => Leads
[name_value_list] => stdClass Object
(
[id] => stdClass Object
(
[name] => id
[value] => d0ecc069-d556-98f3-41f2-53ba1468327a
)
[name] => stdClass Object
(
[name] => name
[value] => John Doe
)
[status] => stdClass Object
(
[name] => status
[value] => New
)
[website] => stdClass Object
(
[name] => website
[value] => web.com
)
[phone_cr] => stdClass Object
(
[name] => phone_cr
[value] => 1-888-888-8888
)
)
)
I'm using a query from the api to filter the results for the user I'm targeting:
'query' => "leads.assigned_user_id='user_ID-here'",
'order_by' => "date_entered DESC",
This works fine. So I've ran a foreach () statement to retrieve only one field on a button click, which also works just fine. What I really need to accomplish is before this statement, a foreach() command (or something else?) to filter out and retrieve ONLY the "New" results in the status value, and from that group output an array showing only the website field. Seen in the "desired end result section of this question."
This is the code I'm filtering the field I'm targeting and having a new array created with if that helps bridge the gap:
$results = call('get_entry_list', $params, $url);
$eresult = array();
foreach ($results->entry_list as $index=>$value_list) {
$listed = $value_list->name_value_list->website->value;
$eresult[] = $listed;}
So the desired end result based on this data should be:
Array
(
[1] => web.com
)
I'm unsure what I need to do to filter the "Status" field to only then be ran with the $eresult array I created to achieve this. To be clear, everything is working as it should, and my print from $eresult is outputting exactly as it should by returning all results in the website value area, I just need some help to get it sorted before going to that step by sorting it by the "new" status first without all the extra 'stuff,' then sorting out the array in my desired format with the foreach() statement above. I tried to cut out all the other code, as it's a pretty long project, so this should be all the relevant information for the particular goal I need to accomplish in this segment. Any help is greatly appreciated! Thank you!
I've decided to create a second script for this as a temp solution by adding:
'query' => "(leads.assigned_user_id='user_ID-here') AND (status='New')"
So I guess that works, I was trying to avoid calling another script for just one separate function, but it is working fine.