0

I am working on a CakePHP 2.x. I want to send data to another url from controller so I can access the data from their.

I want to do something like this :

function senddata(){
   $a = 1;
   $b= hello;
   http://anotherwebsite/$a
}

I want to POST these values to another url. So I can get the values like this

$a = $_POST['a'];

How can I send data to external url from controller ?

3
  • you need to do this with curl, please look at this stackoverflow.com/questions/4254645/… Commented Sep 3, 2013 at 13:34
  • Thats wrong, CakePHP has the HttpSocket class for that. Commented Sep 3, 2013 at 13:44
  • @burzum well i have used the socket class but i am not able to access the variables on my other url .. i mean the url which i have written in http socket Commented Sep 3, 2013 at 13:52

1 Answer 1

1

well i found the solution .. i have done this in order to accomplish this

 App::uses('HttpSocket', 'Network/Http');

    $HttpSocket = new HttpSocket();


$results = $HttpSocket->post(
    'http://example.com/add',
    'name=test&type=user'
);

source: http://book.cakephp.org/2.0/en/core-utility-libraries/httpsocket.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.