Jump to content
  • 0

Getting Content Of A Page By Curl


Question

Posted

I am doing a wordpress plugin that fetch blesta pages using curl. Did login to blesta.

 

When i try to access content of the below link using curl

domain.com/admin/widget/system_overview/admin_main/

 

i'm getting content of page

domain.com/admin/

not that of

domain.com/admin/widget/system_overview/admin_main/

 

Code is below

 

 $tempurl =  'http://domain.com/admin/widget/system_overview/admin_main/';
 $ch = curl_init();
 curl_setopt($ch,CURLOPT_URL,  $tempurl);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                //curl_setopt($ch, CURLOPT_POST, 1);
                //curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
               // curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
   $buffer = curl_exec($ch);    
   echo $buffer;           
   curl_close($ch);

6 answers to this question

Recommended Posts

  • 0
Posted

The main widget method is only available via AJAX, and redirects back to the base URI otherwise. You would need to pass in the appropriate AJAX headers and content type.

  • 0
Posted

@Tyson

 

Do you think we can show the main widget content in wordpress then? is there any technology for that?

 

 

You could fetch the markup for the system overview widget, but it won't look right outside of Blesta because it will be missing all of the CSS/javascript necessary to render it correctly.

  • 0
Posted

You could try:

curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Requested-With: XMLHttpRequest", "Content-Type: application/json; charset=utf-8"));

I haven't tested it, so you may need to play around with it.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...