Welcome Guest, Not a member yet? Register   Sign In
Cant post code!!!!???
#1

[eluser]behnampmdg3[/eluser]
Edit:

Please see post below Smile
#2

[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
#3

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

[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
#5

[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.
#6

[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}";
    }
#7

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

[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
#9

[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!
#10

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




Theme © iAndrew 2016 - Forum software by © MyBB