CodeIgniter Forums
Cant post code!!!!??? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Cant post code!!!!??? (/showthread.php?tid=60167)

Pages: 1 2 3


Cant post code!!!!??? - El Forum - 01-28-2014

[eluser]behnampmdg3[/eluser]
Edit:

Please see post below Smile


Cant post code!!!!??? - El Forum - 01-28-2014

[eluser]behnampmdg3[/eluser]
Trying to conver this code to a class:

Code:
include 'sms.php';
$api=new transmitsmsAPI("6128caf3",'bam');

// sending to a set of numbers
$result=$api->sendSms(
'Hello how are you?', '042444444', '042444444');

// sending to a list
//$result=$api->sendSms('test', null, 'callerid', null, 6151);

if($result->error->code=='SUCCESS')
{
     echo "Message to {$result->recipients} recipients sent with ID
     {$result->message_id}, cost {$result->cost}";
}
else
{
     echo "Error: {$result->error->description}";
}
After conversion:

Code:
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Send_sms extends CI_Controller {


public function index()
  {

   $params = array('6128caf3', 'bam');
   $api = $this->load->library('Mysms', $params);

   //transmitsmsAPI

    
    
    // sending to a set of numbers
    $result=$api->sendSms(
    'Hello how are you?', '********', ''********',');
    
    // sending to a list
    //$result=$api->sendSms('test', null, 'callerid', null, 6151);
    
    if($result->error->code=='SUCCESS')
    {
        echo "Message to {$result->recipients} recipients sent with ID
        {$result->message_id}, cost {$result->cost}";
    }
    else
    {
        echo "Error: {$result->error->description}";
    }
    
     }
}
But doesn't work!. GIves me blank page. Should be an easy thing! Please guide Smile
Thanks


Cant post code!!!!??? - El Forum - 01-29-2014

[eluser]Tpojka[/eluser]
Have you double checked gateway documentation?
Can you edit your post to be readable to anyone?


Cant post code!!!!??? - El Forum - 01-29-2014

[eluser]behnampmdg3[/eluser]
[quote author="Tpojka" date="1390992228"]Have you double checked gateway documentation?
Can you edit your post to be readable to anyone?[/quote]Edit worked! ;p


Cant post code!!!!??? - El Forum - 01-29-2014

[eluser]CroNiX[/eluser]
I believe
Code:
$api = $this->load->library('Mysms', $params);
should be just
Code:
$this->load->library('Mysms', $params);

and then you access it like
Code:
$this->mysms->foo();

This doesn't seem to be correct:
Code:
$result=$api->sendSms(
    'Hello how are you?', '********', ''********',');
There are too many single quotes in the parameters being sent to sendSms()...

Also you should probably post your mysms library if that doesn't work, particularly the constructor since you pass data to it.



Cant post code!!!!??? - El Forum - 01-29-2014

[eluser]behnampmdg3[/eluser]
Hi now I get this:
Quote:Error: The auth data you have provided is invalid.
I think passing $param is not working!
Code:
$params = array('aaa', 'aaaa');
   $this->load->library('Mysms', $params);
   //$api=new transmitsmsAPI("****",'****');
   $result=$this->mysms->sendSms(
    'Hello how are you?', '****', '****');
    
    // sending to a list
    //$result=$api->sendSms('test', null, 'callerid', null, 6151);
    
    if($result->error->code=='SUCCESS')
    {
        echo "Message to {$result->recipients} recipients sent with ID
        {$result->message_id}, cost {$result->cost}";
    }
    else
    {
        echo "Error: {$result->error->description}";
    }



Cant post code!!!!??? - El Forum - 01-29-2014

[eluser]behnampmdg3[/eluser]
Class seems to be too big. I need to attach it somehow?


Cant post code!!!!??? - El Forum - 01-29-2014

[eluser]CroNiX[/eluser]
That means you should be looking at your mysms library, which you didn't post.

Edit: ah, you did when I was posting this. So look at your mysms library constructor which expects 2 parameters, and then look at the single array you are passing it when you instantiate it. Notice something wrong there? Smile


Cant post code!!!!??? - El Forum - 01-29-2014

[eluser]behnampmdg3[/eluser]
[quote author="CroNiX" date="1391040571"]That means you should be looking at your mysms library, which you didn't post.[/quote]I tried Sad

It breaks.

Man something is wrong here I guess. It doesnt like the code!


Cant post code!!!!??? - El Forum - 01-29-2014

[eluser]behnampmdg3[/eluser]
Cant attach either. Gives me blank page.