how to grab product lists from cj, clickbank and linkshare, ebay using api? - api

Hello i want to get the product lists from cj, clickbank and linkshare via API's to display the whole lists on my site , if this is possible or its a nightmare , where am i standing please generous reply is needed, tell me how to grab the product list using their respective API's , i have found alot of blogs and posts regarding this but none is enough to solve my prob, thats y i said a nightmare.
this is what i got for clickbank
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.clickbank.com/rest/1.3/products/list");
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/xml", "Authorization:DEV-7979307A05A8A50B6535A5AD5DCD8EDB060B:API-4D297E18498B51B70EA986DC7422B1BCE488"));
$result = curl_exec($ch);
curl_close($ch);
print_r($result);
the apikey and dev key is the real one of my affiliate account i created , i am giving the real info because i need it to be done, it is throwing the same error , site parameter is missing,
same is what i want for the other two.
much thanks in advance . cheers.

okey the second was linkshare product grabing from linkshare , which is a bit different than other affiliate channels, in a sence that here first you will create relation on the linkshare advertisers , and you can the products of those who will allow you to be his advertiser or affiliate:
here is the code:
$ch = curl_init();
$cv = curl_version();
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
curl_setopt($ch, CURLOPT_URL, "http://productsearch.linksynergy.com/productsearch?token=YOUR-LINKSHARE-TOKEN-ID-A-VERY-LONG-STRING&keyword=%22YOUR-KEYWORD%22&MaxResults=20&pagenumber=1&mid=MID-THE-ID-OF-THE-ADVERTIZER-WHO-HAS-ALLOWED-YOU&sort=retailprice&sorttype=asc&sort=productname&sorttype=asc");
$xml_data = curl_exec($ch);
curl_close($ch);
$object = simplexml_load_string($xml_data);
foreach($object->item as $signprod)
{}
under the foreach loop you can do what ever you want, just print_r($signprod) and you will get the details , put the keyword matching against your allowed advertiser's product, by helping you more say i have a relation with some cookies site, who's MID is xxxxx , then i write cookies in the keyword and it get results for me, do accordingly.
its simple and yeah it will take a long time on net if someone is new like me, which i was before more than a month ago.

Okey , that question i posted was somewhat one and half month before , i know answers are present all around the web but scattered and i want them to be gathered so if some one need it can use it.
first of all i am giving you for CJ, Comission Junction:
1) Creat a page e.g cjcall.php and put the following code on that page.
// CJ Product Grabing cjcall.php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://product-search.api.cj.com/v2/product-search?website-id=YOUR-SITE-ID&keywords=KEYWORD&records-per-page=30&serviceable-area=US");
curl_setopt($ch, CURLOPT_HEADER,false);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/xml", "Authorization:YOUR-CJ-DEVELOPER-ID"));
$result = curl_exec($ch);
THIS will give you responce of products against your keyword if it is matching products.
you can get you result the way you want i figured it this way that i created a new page called cjcronjob.php and put the following code on that page and run it , there you can use the product details, i.e may be save in the database.
//cjcronjob.php
$homepage = file_get_contents('ABSOLUTE-PATH-TO-THE-FIRST-CJCALL.PHP-FILE/cjcall.php');
$object = simplexml_load_string($homepage);
foreach($object->products->product as $cjres)
{
}
nOW each product is in your control use it in here inside the foreach loop which will run twenty times here as specified in the curl call.
clickbank is still a mystery , may be they dont allow you to perform more against their API

Related

WORDPRESS Database How to return meta value from database?

I have in database this meta_key fw:ext:mm:io:primefeed and this meta_value a:5:{s:4:"type";s:6:"column";s:3:"row";a:0:{}s:6:"column";a:1:{s:14:"item_thumbnail";a:2:{s:13:"attachment_id";s:2:"11";s:3:"url";s:49:"//primefeed.loc/wp-content/uploads/2020/01/01.jpg";}}s:4:"item";a:0:{}s:7:"default";a:0:{}}
How to return this meta value (link) //primefeed.loc/wp-content/uploads/2020/01/01.jpg ?
That's a PHP serialized array. You can see the structure using
print_r( unserialize( $value ) );
e.g. repl.it demo
Inside WordPress, you can do
$meta_value = get_post_meta($post_id, "fw:ext:mm:io:primefeed", true);
$url = $meta_value["column"]["item_thumbnail"]["url"];
where get_post_meta does both the database fetch and unserialize.

How do i check Instamojo payment confirmation?

After successful payment, Webhook url is called which contains information such as payment id and other details. If two or more persons simultaneously did payment. And each one using different payment links. Whether the post information returning will get to the corresponding person? Or whether there is a chance to misplace the post information to any other person?
How can i confirm that the return payment info get to the same person who made payment? Is there any way to attach some value to the payment link from the seller site to identify the person who made payment??
POST request sent to Webhook URL will contain the data entered by the user during the payment including their name, email, phone.
If you're using same Webhook URL for different payment links then also you can identify which Payment link was used to make this payment. The POST request contains fields like offer_slug and offer_title which can be used to identify the Payment link used.
If that is not enough then you can define custom fields for your links and pass some custom data with them. Check Instamojo's integration documentation for more details.
Respected,
Few Days back i was working with integration of instamojo in my web app,
Webhook will provide you title,payment_id,buyer_email,buyer_name,buyer_phone,status,offer_slug,amount,mac and few more params.
With the above provided you can determine which user chosen link to pay.
Solution : Before simply redirecting to the link for payment,
Just assemble request specified in Documentation adding Email,name and phone as params and make it read only so that it can't be changed while proceeding to payment.
Adding hmac-sha1 verify will also tighten the integrity check.
I would suggest you to go through the documentation twice for more understanding and clarification.
You have to pass X-Api-Key and 'X-Auth-Tokenand after transaction you will get 2 valuespayment_request_idandpayment_id` pass this 2 you will get transaction details:
$requestid = Input::get('payment_request_id');
$paymentid = Input::get('payment_id');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.instamojo.com/api/1.1/payment-requests/'.$requestid.'/'.$paymentid.'/');
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER,
array("X-Api-Key:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"X-Auth-Token:bbbbbbbbbbbbbbbbbbbbbbbbbbb"));
$payload = Array(
'purpose' => 'FIFA 16',
'amount' => '2500',
'phone' => '9999999999',
'buyer_name' => 'John Doe',
'redirect_url' => 'http://www.example.com/redirect/',
'send_email' => true,
'webhook' => 'http://www.example.com/webhook/',
'send_sms' => true,
'email' => 'foo#example.com',
'allow_repeated_payments' => false
);
$response = curl_exec($ch);
curl_close($ch);
$transactiondata = json_decode($response , true);

How to get invoice details using PayPal API?

I must say, I can't remember the last time I've spent so much time figuring out an API. I loathe working with PayPal. That said...
I'm developing a seemingly simple script to download transactions into shipping software. I've got the script working to pull transactions in NVP and SOAP. But when a payment is on an invoice, the items purchased aren't included in the payment transaction info. So I'm assuming what I need is in the invoicing API.
I have API credentials that work just fine with TransactionSearch. I saw that for the Invoicing API, I also need an App Id, so I created an App, twice. Apparently there are two PayPal developer sites?? So I have a REST app created at developer.paypal.com and I guess a classic app "conditionally approved" at apps.paypal.com.
I guess after venting about the ridiculously unorganized developer structure and the sad excuse for documentation... !##$ ... I'd like to find out if anyone can get me on the right track.
All I need to be able to do is see what invoices have come in (start-end date, etc) and get the details so it can be exported to our shipping software. Transactions work just fine, I'm not sure why invoices are so different or why there's so much more involved in getting that data?
Just as a reference, here's how we're pulling in our transactions:
$client = new SoapClient( 'https://www.paypal.com/wsdl/PayPalSvc.wsdl',
array(
'location' => 'https://api-3t.paypal.com/2.0/',
'soap_version' => SOAP_1_1
));
$cred = array( 'Username' => $username,
'Password' => $password,
'Signature' => $signature
);
$Credentials = new stdClass();
$Credentials->Credentials = new SoapVar( $cred, SOAP_ENC_OBJECT, 'Credentials' );
$headers = new SoapVar( $Credentials,
SOAP_ENC_OBJECT,
'CustomSecurityHeaderType',
'urn:ebay:apis:eBLBaseComponents' );
$client->__setSoapHeaders( new SoapHeader( 'urn:ebay:api:PayPalAPI',
'RequesterCredentials',
$headers ));
$args = array(
'Version' => '94.0',
'StartDate' => '2014-03-25T00:00:00Z'
);
$TransactionSearchRequest = new stdClass();
$TransactionSearchRequest->TransactionSearchRequest = new SoapVar( $args,
SOAP_ENC_OBJECT,
'TransactionSearchRequestType',
'urn:ebay:api:PayPalAPI');
$params = new SoapVar($TransactionSearchRequest, SOAP_ENC_OBJECT, 'TransactionSearchRequest');
$result = $client->TransactionSearch($params);
print_r($result);
First, if you want to simplify your development with PayPal API's I'd recommend taking a look at my PHP class library for PayPal. It makes things much easier.
As for obtaining invoice details, you're correct that the Invoicing API is actually built on PayPal's Adaptive Payments platform which includes the App ID. I guess I'm a little confused on if you got that done or not..??
Once you have the APP ID, though, you can make the GetInvoiceDetails call to retrieve the invoice details.

Wikipedia API - grab 'Background Inforamtion' Table?

Does MediaWiki provide a way to return the information present in 'Background Information' Table? (usually right of the article page) For example I would like to grab the Origin from Radiohead:
http://en.wikipedia.org/wiki/Radiohead
Or do I need to parse the html page?
You can use the revisions property along with the rvgeneratexml parameter to generate a parse tree for the article. Then you can apply XPath or traverse it and look for the desired information.
Here's an example code:
$page = 'Radiohead';
$api_call_url = 'http://en.wikipedia.org/w/api.php?action=query&titles=' .
urlencode( $page ) . '&prop=revisions&rvprop=content&rvgeneratexml=1&format=json';
You have to identify yourself to the API, see more on Meta Wiki.
$user_agent = 'Your name <your email>';
$curl = curl_init();
curl_setopt_array( $curl, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERAGENT => $user_agent,
CURLOPT_URL => $api_call_url,
) );
$response = json_decode( curl_exec( $curl ), true );
curl_close( $curl );
foreach( $response['query']['pages'] as $page ) {
$parsetree = simplexml_load_string( $page['revisions'][0]['parsetree'] );
Here we use XPath in order to find the Infobox musical artist's parameter Origin and its value. See the XPath specification for the syntax and such. You could as well traverse the tree and look for the nodes manually. Feel free to investigate the parse tree to get a better grip of it.
$infobox_origin = $parsetree->xpath( '//template[contains(string(title),' .
'"Infobox musical artist")]/part[contains(string(name),"Origin")]/value' );
echo trim( strval( $infobox_origin[0] ) );
}
MediaWiki as installed on Wikipedia provides no way to get this information (there are extensions such as Semantic MediaWiki that are designed for this sort of thing, but they are not installed on Wikipedia). You can either parse the output HTML or parse the page's wikitext, or in certain cases (e.g. birth/death year) you might be able to look at the page's categories via the API.
It's a steep learning curve but DBpedia does what you want.
The "Background information table" you mention is called an "Infobox" in Wikipedia parlance and DBpedia allows very powerful queries on them. Unfortunately because it's powerful it's not easy to learn and I've mostly forgotten what I learned about it a year or two ago. I'll paste a query here though if I manage to learn it again (-:
In the meantime, here is DBpedia's idea of an introduction in how to use it.
This previous SO question will help: Getting DBPedia Infobox categories
UPDATE
OK here is the SPARQL query:
SELECT ?org
WHERE {
<http://dbpedia.org/resource/Radiohead> dbpprop:origin ?org
}
Here is a URL where you can see it working and play with it.
And here is the output on that page: (you can get output in various formats too)
SPARQL results: org "Abingdon,
Oxfordshire, England"#en

Update specific field on SOLR index

I want to using solr for search on articles
I have 3 table:
Group (id , group name)
ArticleBase (id, groupId, some other field)
Article(id, articleBaseId, title, date, ...)
in solr schema.xml file i just define all article field that mixed with ArticleBase table (for use one index on solr) like this: (id, articleBaseId, groupId, ...)
problem: Admin want to change group (ArticleBase), therefore i must update (or replace) all indexed article in solr. right ? can i update groupId only in solr index ?
have any solution ?
Note:Article table contains more than 200 million article, and i using solr for index only (not store any field data except article id)
Solr does not support updating individual fields yet, but there is a JIRA issue about this (almost 3 years old as of this writing).
Until this is implemented, you have to update the whole document.
UPDATE: as of Solr 4+ this is implemented, here's the documentation.
Please refer to this document about the "Partial Documents Update" Feature in Solr 4.0
Solr 4.0 is now final and production-ready.
This feature makes it possible to update fields and even adding values to multiValued fields.
Mauricio was right with his answer back in 2010, but this is the way things are today.
SolrPHP doesn't provide any method to update a specific field in Solr.
However, you can make a Curl call in PHP to update a specific field:
<?php
// Update array
$update = array(
'id' => $docId,
$solrFieldName => array(
'set' => $solrFieldValue
)
);
$update = json_encode(array($update));
// Create curl resource and URL
$ch = curl_init('http://'.SOLR_HOSTNAME.':'.SOLR_PORT.'/'.SOLR_COLLECTION.'/update?commit=true');
// Set Login/Password auth (if required)
curl_setopt($ch, CURLOPT_USERPWD, SOLR_LOGIN.':'.SOLR_PASSWORD);
// Set POST fields
curl_setopt($ch, CURLOPT_POST,true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $update);
// Return transfert
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Set type of data sent
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
// Get response result
$output = json_decode(curl_exec($ch));
// Get response code
$responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Close Curl resource
curl_close($ch);
if ($responseCode == 200)
{
echo 'SOLR: Updated successfully field '.$solrFieldName.' for id:'.$docId.' (query time: '.$output->responseHeader->QTime.'ms).';
}
else
{
echo ('SOLR: Can\'t update field '.$solrFieldName.' for id:'.$docId.', response ('.$responseCode.') is: '.print_r($output,true));
}
I use this code to update in JSON, you can also provide data in XML.
My Solution was something as below:
$client = new SolrClient($options);
$query = new SolrQuery();
// Find old Document
$query->setQuery('id:5458');
$query->setStart(0);
$query->setRows(1);
$query_response = $client->query($query);
// I had to set the parsemode to PARSE_SOLR_DOC
$query_response->setParseMode(SolrQueryResponse::PARSE_SOLR_DOC);
$response = $query_response->getResponse();
$doc = new SolrInputDocument();
// used the getInputDocument() to get the old document from the query
$doc = $response->response->docs[0]->getInputDocument();
if ($response->response->numFound) {
$second_doc = new SolrInputDocument();
$second_doc->addField('cat', "category123");
// Notice I removed the second parameter from the merge()
$second_doc->merge($doc);
$updateResponse = $client->addDocument($second_doc);
$client->commit();
}
You can refer to this documentation for Partial Updates. You can make an update either by replacing it or adding more values to that particular field although (like a list), it's not required in your case
Solr supports different types of Update Operations.
The set of update operations supported by Solr.
'add' - add a new value or values to an existing Solr document field, or add a new field and value(s).
'set' - change the value or values in an existing Solr document field.
'remove' - remove all occurrences of the value or values from an existing Solr document field.
Here is an example of how to do a partial update via Solr’s Java client, SolrJ
// create the SolrJ client
HttpSolrClient solrClient = new HttpSolrClient("http://localhost:8983/solr");
// for clould there is CloudSolrClient api
// create the document
SolrInputDocument solrDocument = new SolrInputDocument();
solrDocument.addField("id","12345");
Map<String,Object> solrUpdates = new HashMap<>(1);
solrUpdates.put("address","Pune");
solrDocument.addField("cat", solrUpdates);
solrClient.add( solrDocument );
solrClient.close();