Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Send Messages #11

Open
jasonclemons opened this issue Jul 7, 2013 · 17 comments
Open

Feature Request: Send Messages #11

jasonclemons opened this issue Jul 7, 2013 · 17 comments
Assignees
Milestone

Comments

@jasonclemons
Copy link
Member

Ability to send messages via Xbox LIVE from authed user. Must keep Xbox's message limits in mind (100 messages per day?)

@ghost ghost assigned jasonclemons Jul 7, 2013
@CGollhardt
Copy link

Would be very nice.
+1

@noobmasta
Copy link

I don't know if you have made any progress but I managed to accomplish sending messages with your awesome open sourced Api, just had to modify slightly.. only prob is that it's got to be a gold account to send from Xbox.com. let me know I'm more then willing to contribute seeing how your api saved me tons of work. Keep it up!

@chumpp
Copy link

chumpp commented Jun 15, 2014

@noobmasta I would like to see that. Can you help us out?

@djekl
Copy link
Contributor

djekl commented Jun 16, 2014

Please do a pull request, don't submit code in an issue

Sent from my iPhone

On 16 Jun 2014, at 09:03 pm, noobmasta notifications@github.com wrote:

@chumpp you ask and you shall receive!

i haven't done much to make it pretty, i just kinda left it to show xbox's response in the data{} field for my own debugging. if anyone wants to spend more time and effort to clean it up or add more to it let me know please!

in my /api directory i added 'sendmessages.php'

output_headers(); $gamertag = (isset($_GET['gamertag']) && !empty($_GET['gamertag'])) ? trim($_GET['gamertag']) : null; $message = (isset($_GET['message']) && !empty($_GET['message'])) ? trim($_GET['message']) : null; $region = (isset($_GET['region']) && !empty($_GET['region'])) ? $_GET['region'] : 'en-US'; if (!$api->logged_in) { echo $api->output_error(500); } else { if (empty($gamertag)) { echo $api->output_error(301); } elseif (empty($message)) { ``` echo $api->output_error(307); /* i also added a error message saying 'no message supplied' in the '/includes/classes/base.class.php' */ } elseif ($api->check_culture($region) == false) { echo $api->output_error(305); } else { $data = $api->send_livemessage($gamertag, $message, $region); if ($data) { echo $api->output_payload($data); } else { echo $api->output_error($api->error); } } ``` } ?>

now just add my function to the bottom of '/api/includes/classes/api.class.php' just above the last bracket '}'

/**
 * Send Message (by: admin@xblnoobs.com)
 *
 * @access public
 * @var    string $gamertag
 * @var    string $message
 * @var    string $region
 * @return array
 */
public function send_livemessage($gamertag, $message, $region)

{
$gamertag = trim($gamertag);
$urltag = str_replace(' ', '%20', $gamertag); /*added so it would message gamertags with spaces instead of just the first half of the gamertag

    //$message   = str_replace(' ', '+', $message); //dont think its necessary anymore after testing        */

    $url       = 'https://live.xbox.com/' . $region . '/Messages?gamertag='.$urltag;

        $data      = $this->fetch_url($url);
        $post_data = 'recipients='.urlencode($gamertag).'&message='.urlencode($message).'&__RequestVerificationToken=' . urlencode(trim($this->find($data, '<input name="__RequestVerificationToken" type="hidden" value="', '" />')));
        $headers   = array('X-Requested-With: XMLHttpRequest', 'Referer: '.$url, 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8');
        $data      = $this->fetch_url('https://live.xbox.com/' . $region . '/Messages/SendMessage', $url, 10, $post_data, $headers);

    //the following is commented out due to random failures in the script
    //$checkme = strpos($data, 'Success\":true');
    //if($checkme === false){   $ok = 'Error! Message not sent? | $data= '.$data;
    //}else{    $ = 'Message Sent?  |   $data= '.$data ; }


    return $data;
}

there you guys go... keep in mind i have NOT dumb proofed it at all. (so be careful not to spam xbox with messages)

it should output "data": "{"Success":true,"Diagnostics":null}", when its successful.


Reply to this email directly or view it on GitHub.

@chumpp
Copy link

chumpp commented Jun 16, 2014

@noobmasta Awesome, thanks!

@noobmasta
Copy link

@djekl sorry im nott too github friendly

@jasonclemons
Copy link
Member Author

While that allows you to send messages, it doesn't account for the Xbox message limit (100 per day).

@djekl
Copy link
Contributor

djekl commented Jun 16, 2014

Also, sending/receiving is only for the logged in account

Sent from my iPhone

On 16 Jun 2014, at 09:13 pm, Jason Clemons notifications@github.com wrote:

While that allows you to send messages, it doesn't account for the Xbox message limit (100 per day).


Reply to this email directly or view it on GitHub.

@djekl
Copy link
Contributor

djekl commented Jun 16, 2014

@noobmasta Fork the repo, make your changes (either on GitHub or in your editor of choice, then use the GitHub app to commit back). Then you can submit a pull request back to us here.

Sent from my iPhone

On 16 Jun 2014, at 09:09 pm, noobmasta notifications@github.com wrote:

@djekl sorry im nott too github friendly


Reply to this email directly or view it on GitHub.

@noobmasta
Copy link

im aware of all that guys.. i did say i havent dumb proofed it or made the output pretty.. i kinda stopped working on it months ago and caught a random email asking about it..(reason i made a github account was to comment on your work) sorry just thought i would help out someone. it does work somewhat however and im still looking forward updates on your work

edit: @jasonclemons i also think its limited to 250 characters

@noobmasta
Copy link

so i randomly started using your guys api again because i noticed xbox.com allows silver to send messages now.. awesome right? well now my api doesnt work at all... "Could not login to Windows Live. Please email support@xboxleaders.com." is the message it puts out when just trying to load a profile. has the cookie for xbox.com changed or something becuase the layout and requesttokens look the same to me

@jasonclemons
Copy link
Member Author

The entire layout for xbox.com has changed, and I have no time nor energy to get a rewrite pushed out. At this time, you would be better off using https://xboxapi.com

@noobmasta
Copy link

bummer dude. i went back to scraping my own data from another site for speed awhile ago.. but when i noticed you can send stuff from silver i reinterested myself in your api cuz it actually logged in and created cookies for the accounts, not because i need it to fetch data. guess ill let you know if i get it figured out. thanks anyway

@djekl
Copy link
Contributor

djekl commented Sep 3, 2014

@jasonclemons Thanks for the recommendation.

@noobmasta Yes, unfortunately because the new xbox.com changes require Javascript on pages, a rewrite of the api would be extensive as discussed in a previous issue about the profile pages.

@noobmasta
Copy link

yea i just now read the major issue... sorry i had no idea when i first asked.. i just was paying attention to the source of the messages page and post packetdata compared to what was already wrote. wasnt interested in the profile data

@djekl
Copy link
Contributor

djekl commented Sep 3, 2014

@noobmasta Yeah no worries m8, was just simpler for me to point you there then write it again

@drmarshall
Copy link

Looks like #78 added send message functionality

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants