I am a newbie to the whole concept of the Bigcommerce Api, but my php programming is good.
I am having problems with identifying where to start exactly if i am going to integrate the php code that I may have created with the bigcommerce api,
Where do my files go? How do they interact exactly...
On the Bigcommerce site, they define what its all about, and provide the basic php codes.
Google is my friend but she hasn't been able to help me with links for the whole "How to get started" part...
Or maybe I am asking her the wrong questions.
My ultimate task is to take data from an xml file and use php to handle the rest of the processing and displaying..
I am a newbie and I am not sure how it really works. But links to proper tutorials will really help
Apparently i had no idea Big-commerce doesn't need me to host any server code on their side or whatever,
i found out that which ever code i write is simply run on my side so i can interact with my store.
i wonder why i couldn't really find this information anywhere easily, shouldn't it be the first thing we see when we reach the developers page on bigcommerce.com??
Anyway, i found what i was looking for and i understand how it works now.
To begin, as far as where do your PHP scripts go, those will be hosted external to your Bigcommerce store from any server that has PHP installed or from your local computer. The Bigcommerce API basically gives you a way to access and make changes to your store's database using a program. You will interact with API resources endpoints (URLs) which have been tied to specific store related data, like your products or orders. You can make GET, PUT, POST, and DELETE requests on these URLs in order to pull, modify, create, or delete store related data, respectively.
the php files are here https://github.com/bigcommerce/bigcommerce-api-php ,
and these should be in your machine with a PHP server
to get started there are sample codes there also.
i had problems with this line
require 'vendor/autoload.php';
so i changed it to
require 'path_to_this_file/bigcommerce.php';
everything is working fine now...
but iam still learning more
Have a look at this Link for the list of Resources.
Your php file will be making calls to BigCommerce API, to get data from BigCommerce Store.
Simple cURL snippet to get orders.
$api_url = 'https://YOUR-API-PATH.mybigcommerce.com/api/v2/orders.json';
$ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, $api_url );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array ('Accept: application/json', 'Content-Length: 0') );
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
curl_setopt( $ch, CURLOPT_USERPWD, "YOUR-USERNAME:YOUR-API-TOKEN" );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
$response = curl_exec( $ch );
$result = json_decode($response);
print_r($result);
Hope this helps.
For that you can not make directly call to your store front..for that make request from third party server to get your store Api.
call bellow php code by Ajax request...
like that..
----------Php Code:-
$username='username';//API User name
$password='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';//API Token
$URL='https://store-xxxxxxx.mybigcommerce.com/api/v2/products';//API path
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$URL);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:UTF-8','Accept: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); code
$result=curl_exec ($ch);
curl_close ($ch);
print_r($result);//Your Requested Data
Related
Seems like a simple task but despite having read their docs I can't figure it out. I've gotten a Storefront Access Token, as per https://help.shopify.com/en/api/storefront-api/getting-started. Then I've used it in the CURL request below. However this just returns: {"errors":"[API] Invalid API key or access token (unrecognized login or wrong password)"}
I found their documentation a bit confusing as they have quite a few different APIs, and whilst it seems that this Storefront Access Token should work for this particular API, perhaps it doesn't?
$url = "https://mysite.myshopify.com/admin/api/2019-07/products/count.json";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$headers = array(
'X-Shopify-Storefront-Access-Token: 2400d...........a999'
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
print_r( $result);
curl_close($ch);
If you are using the Stronfront API your request should point to
https://mysite.myshopify.com/api/2019-07/products/count.json
and not to
https://mysite.myshopify.com/admin/api/2019-07/products/count.json
In addition Storefront Api request are different from the standard ones, have that in mind.
I'm trying to use the twitter api to make a login to my website this is my first time using any api so its really confusing for me i have read a bit online searching how to make the OAuth and found a project on git-hub which allows us to connect but this will not help me to learn php so i tried the twitter documentation and found this page. The diagram in that page shows that i should post the data to the twitter api urls again searched for on google and found a stackoverflow question but don't know how to use this is there any other tutorial or book that explains all of this? This is what i understood from reading the twitter documentation if im wrong please help me rectify my mistake
Your have to first get a request token.
Try this method, it should work (not tested) :
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://api.twitter.com/oauth/request_token');
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC ) ;
curl_setopt($ch, CURLOPT_USERPWD, $clientId.":".$clientSecret);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($yourPost));
$response = curl_exec($ch);
Then follow the instruction of step 2 using CURL with GET
we are currently trying to integrate into the Netsuite webservice, however we do not wish to use their PHP connector kit. we have already got a script we have developed using Coldfusion and cfhttp to post data into Netsuite without any issue.
Right now we currently have the scripts converted into PHP and are using the curl function to send data to Netsuite.
We can successfully create a new sales order record without any issue, however obtaining the return response message is proving to quite difficult as all we are getting is 302 redirects.
Im assuming that this may have something to do with login credentials for performing the collecting of the return object, however I have no idea on how to store this data in a cookie value so it can continue to be read across the system to system integration.
Below is our CURL code
$http_header = array(
'Content-Type: text/xml; charset="utf-8"',
'SOAPAction: getItemAvailability',
'Content-Length: ' . strlen($myXml),
'Accept: text/xml',
'Cache-Control: no-cache',
'Pragma: no-cache'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->wdsl);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $http_header);
curl_setopt($ch, CURLOPT_POSTFIELDS, $myXml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
$returnObj = curl_exec($ch);
curl_close($ch);
we have tried various things but cannot seem to get it to work so we can obtain the return xml data, its creating the records with no issue what so ever.. Any suggestions would be greatly appreciated
I would recommend using a wrapper library instead of curl for NetSuite communication. I've done a lot of work with the ruby wrapper and it's worked great for me.
One of the reasons you can get a 302 is that account you are trying to access is in a different datacenter than the current WSDL you are pointing to. The standard WSDL domain is system.netsuite.com but many NetSuite installations are on system.na1.netsuite.com. The easiest way to check which datacenter you are on is to login to the GUI and look at the domain.
I have a review board running on different server . I am using review board as a normal user of it and can comment on the reviews create it but i am not the admin f it. In order to view the review request or comment on it, i need to authenticate with it with my username and password. This is the access given to me. Review Board is an open source tool which is used by many organisations.
Here are the WEB API of it:- (authenticating link) http://www.reviewboard.org/docs/manual/1.5/webapi/2.0/authenticating/#logging-in
Now i am using wamp as server on my local system . I am using php as server side language. I want to use the Review Board API for fetching the data with my credientals. I am using php curl and written this code for authenticating:-
<?php
$ch = curl_init('http://SERVERIP');
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Basic realm="Web API"'));
$output = curl_exec($ch);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Basic md5encryptedusernamepassword'));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
var_dump($info);
curl_close($ch);
var_dump($output);
?>
This code is not authenticating. Please have a look. Any kind of guideline will be helpful. I have spent much time understanding it. Please help.
You should set headers with key:"Authorization",value:" Basic #{Base64.encode64("username:password")}"。
Then you can access the api which is need authentication.
I am still fairly new at playing with PHP. I wanted to poke at a small project. I have the ability to access an xml feed from our calendar system at work. The feed requires authentication with a username and password. I am trying to automate pulling this feed. My hope is to one day use it to automate the scheduling of another system but for now I'm just trying to get this side working.
I have read through some of the cURL documentation on php.net. I have also searched through stackoverflow for a few examples. They were helpful in getting me started but not much further. Below is what I have so far. But all I get back is:
UNAUTHORIZED The request requires
authorization
So I'm racking my head to figure out what might be the issue. Part of my problem I'm sure is my ignorance with the actual process behind what is going on between the client and server. When I interact with it normally I just go to the feed URL, the browser prompts me for a username and password, and then after putting that in it gives me an xml page.
I've checked for most of the formatting errors and syntax errors I knew to look for. That may still be it but at this point I think it's more my lack of understanding how it all fits together. Thanks for any help.
Similar issues:
Parsing XML data with Namespaces in PHP
CURL HTTP Authentication at server side
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://somesight.someplace.edu/r25ws/servlet/wrd/run/events.xml");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "username:password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
?>
I figured it out on my own after looking at a similar tutorial for Twitter. I tried a different approach to formatting the options and it worked fine. I also cut down on the number of options I was sending because it seemed like overkill. Code that works below.
<?php
$username = 'myusername';
$password = 'mypassword';
$datecall = curl_init("http://somesite.someplace.edu/r25ws/servlet/wrd/run/events.xml");
curl_setopt($datecall, CURLOPT_USERPWD, $username.":".$password);
curl_setopt($datecall, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($datecall);
echo $result;
?>