Categories
Mastering Development

I can not log in to the site through curl

I can’t understand what I’m doing wrong. There is a service site: https://demo.moneta.ru/login.htm. The usual form with a token. I knock on the page, save the cookies, take the token from the form. The next request I send to the address from the form data. With cookies and token. I get a fig. 401. I […]

Categories
Development

PHP “echo” not working before curl function

funtion request(){ echo “Success”; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, $request_timeout); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $request_timeout); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($ch); $curl_error = curl_errno($ch); $getserver = curl_getinfo($ch); curl_close($ch); } here success echo only shows after exicuting curl function . i wanna echo the success message before curl function calls.

Categories
Development

PHP CURL not working on multi-dimenstional array

I have a PHP script to update contact details via CURL, it has to do 2 updates, one to clients, 1 to contacts. The clients bit works, but the contacts just updates the database with blanks, it doesn’t leave the values, it completely wipes them, can anyone see a reason for this? Thanks Code below: […]

Categories
CMS Development Wordpress

Loading pages without redirecting in WordPress

I am trying to load pages in WordPress using Ajax. Here’s what I have so far: Javascript: $(‘body’).on(‘click’, ‘a:not([href^=”#”])’, function(e) { if ( this.host === window.location.host ) { e.preventDefault(); replace_main($(this).attr(‘href’)); } }); function replace_main(url) { $.ajax({ url: ajax_var.ajax_url, type: ‘POST’, data: { action: ‘page_content’, url: url }, success: function(response) { $(‘main’).html(JSON.parse(response)[‘content’]); } }); } PHP: […]

Categories
Development

libcurl Error: “Peer certificate cannot be authenticated with given CA certificates”

I am trying to connect to a FreeBSD server from Mac OS X (High Sierra) through HTTPS. We are using self-signed certificate. I am downloading the certificate using the command /usr/bin/openssl s_client -tls1_2 -connect 192.168.5.140:443 The code I am using to connect is curl_easy_setopt(curl, CURLOPT_URL, Serveraddress); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 60); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, request); curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); […]

Categories
Development

Unable to receive inbound XML sent via cURL on remote API server

I am tasked with building an API to receive inbound XML data. On my client, I have this code. $url = “http://stackoverflow.com”; $xml = ‘<?xml version=”1.0″ encoding=”UTF-8″?><Request PartnerID=”asasdsadsa” Type=”TrackSearch”> <TrackSearch> <Title>love</Title> <Tags> <MainGenre>Blues</MainGenre> </Tags> <Page Number=”1″ Size=”20″/> </TrackSearch> </Request>’; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt( $ch, CURLOPT_HTTPHEADER, array(‘Content-Type: text/xml’)); curl_setopt( $ch, […]

Categories
Development MySQL

TelegramBot – Move button to new line

How to make the buttons be in a column, and not in a row. Example Image, as I need: [Click Imgur][1]. function sendInlineKeyboard($id_chat, $text, $array) { $keyboard = array(“inline_keyboard” => array($array)); $toSend = array(‘method’ => ‘sendMessage’, ‘chat_id’ => $id_chat, ‘text’ => $text, ‘resize_keyboard’ => true, ‘reply_markup’ => $keyboard); isset($mark) ? $toSend[‘parse_mode’] = $mark : ”; […]

Categories
Development

Docusign Connect: Error – The request was aborted: Could not create SSL/TLS secure channel

After 4 years of reliable operation, my PHP listener script started to fail from October 8th, 2019 onwards with the “Error – The request was aborted: Could not create SSL/TLS secure channel.” I have not changed anything on my server. The SSL certificate is a valid v3 from Lets Encrypt. TLS is 1.2. I have […]

Categories
Development HTTP

Download https image using php curl. Operation timed out [on hold]

I want to download a remote image using php. The image opens in browser. I have tried the below code but the image is not saving to my server. It is giving error : Operation timed out after 10001 milliseconds with 0 out of -1 bytes received. <?php $img=’https://www.newark.com/productimages/standard/en_US/4550139.jpg’; //$img=’http://www.newark.com/productimages/standard/en_US/4550139.jpg’; $fullpath=’cache/test.jpg’; // cache folder is […]

Categories
Development JSON PHP

json_decode url instagram return Null with PHP code

i have a question from json_decode url instagram https://www.instagram.com/username/?__a=1 return Null with php $newwul = “http://www.instagram.com/username/?__a=1”; $xo = connect($newwul); $xx = json_decode($xo,true); $endcount = $xx[‘logging_page_id’]; $userid = $xx[‘graphql’][‘user’][‘id’]; var_dump($xo);//return NULL var_dump($xx);//return NULL they is my function connect function connect($urlx){ $cookie_file_path = “cookies/c.txt”; $agent = “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) […]